WMI remote call in python script to create process on remote windows computer

Dave Angel davea at ieee.org
Thu Oct 8 03:57:34 CEST 2009


David Jackson wrote:
> ok, cut and pasted, but changed the username/password to protect the innocent.
> this is from interactive prompt.
> let me know if i am still not doing the slashes correctly please.
> i doubt authentication is the issue.; i can get pid information using
> WQL queries.
> objCreateProc.Create expects 4 strings (not objects?), right?
>
> version info:
>   
>>>> sys.version
>>>>         
> '2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)]'
>
>   
>>>> import win32com.client
>>>> computer = "servername"
>>>> strUser = "servername\\my_account"
>>>> strPassword ="shh_secret"
>>>> objSWbemLocator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
>>>> objSWbemServices = objSWbemLocator.ConnectServer(computer, r"root\cimv2",strUser,strPassword)
>>>> objCreateProc = objSWbemServices.Get("Win32_Process")
>>>> ProcessID  = u"200"
>>>> objCreateProc.Create(u"cmd /c ping 127.0.0.1 >>c:\\temp\\finall.log",u"c:\\temp",u' ',ProcessID )
>>>>         
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: 'int' object is not callable
>
>
> how can i see the method available?
>   
>>>> help(objCreateProc) just gives me "Help on instance of CDispatch in module win32com.client:"
>>>>         
>
> Thanks
> David
>
>   
Looks to me like 

objCreateProc.Create has an integer value.

You could add a print for that value before the call to objCreateProc.Create().  (Leave off the parentheses on the print statement)

My guess is that you've got an address there, but I have no idea how to convert that to a valid Python function pointer.  Is there reasonable docs for WMI somewhere?

DaveA






More information about the Python-list mailing list