win32com (VBScript to Python) problem
Rony Steelandt
bucodi at wanadoo.fr
Tue Nov 25 06:27:36 EST 2003
Not knowing exactly what you want to do, just a question.
Why use COM, shutdown is an exe so why not just execute it?
Rony
"Tim Howarth" <tim at worthy.demon.co.uk> a écrit dans le message de news:
d715dc564c.tim at worthy.demon.co.uk...
>
>
> 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:{impersonationLevel=impersonate,(Shutdown)}!\\"_
> & pc & "\root\cimv2")
>
> Set colOperatingSystems = oWMI.ExecQuery("Select * from
Win32_OperatingSystem")
>
> For Each obj in colOperatingSystems
> obj.Win32shutdown 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.Win32ShutDown)
> gives int
>
> print obj.Win32ShutDown
> gives 87 - the ASCII code of "W" - coincidentally ?
>
>
>
>
> import win32com.client, sys
>
>
> pc='MyPC'
>
> oWMI =
> win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate,\
> (Shutdown)}!\\" + pc + r"\root\cimv2")
>
> colOperatingSystems = oWMI.ExecQuery(r"Select * from
Win32_OperatingSystem")
>
> for obj in colOperatingSystems:
> obj.Win32ShutDown(12)
>
>
>
>
> --
> ___
> |im ---- ARM Powered ----
More information about the Python-list
mailing list