I'm (very non expert) trying to use a snippet of VBScript (to shut down
Windows workstations) converted to Python but have hit a problem.
The VBScript below work fine;
pc="MyPC"
Set oWMI=GetObject( "winmgmts:{impe rsonationLevel= impersonate,(Sh utdown)}!\\"_
& pc & "\root\cimv 2")
Set colOperatingSys tems = oWMI.ExecQuery( "Select * from Win32_Operating System")
For Each obj in colOperatingSys tems
obj.Win32shutdo wn 12
Next
but my translation results in "'int' object is not callable" with the
attempted call to Win32Shutdown.
This is with Python 2.3.2 win32all 1.57 or Active Python 2.3.2
print type(obj.Win32S hutDown)
gives int
print obj.Win32ShutDo wn
gives 87 - the ASCII code of "W" - coincidentally ?
import win32com.client , sys
pc='MyPC'
oWMI =
win32com.client .GetObject(r"wi nmgmts:{imperso nationLevel=imp ersonate,\
(Shutdown)}!\\" + pc + r"\root\cimv 2")
colOperatingSys tems = oWMI.ExecQuery( r"Select * from Win32_Operating System")
for obj in colOperatingSys tems:
obj.Win32ShutDo wn(12)
--
___
|im ---- ARM Powered ----
Comment