WMI remote call in python script to create process on remote windows computer
mail at timgolden.me.uk
Thu Oct 8 10:58:49 CEST 2009
> On Oct 8, 10:22 am, Tim Golden <m... at timgolden.me.uk> wrote:
>> 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?
>> Invoking a method isn't as easy as that, I'm afraid. At
>> the risk of being boring, can I ask again why you aren't
>> using the wmi module, which solves these problems for
>> In short you want to do something like this:
>> (simplified for testing purposes to use the local machine)
>> import win32com.client
>> wmi = win32com.client.GetObject ("winmgmts:")
>> win32_process = wmi.Get ("Win32_Process")
>> in_parameters = win32_process.Methods_ ("Create").InParameters
>> in_parameters.Properties_ ('CommandLine').Value = "notepad.exe"
>> result = win32_process.ExecMethod_ ("Create", in_parameters)
> Good point, I would like just to add this:
> wmi = win32com.client.GetObject ("winmgmts:\\\\username:password at host\
> and it is perfect :)
I wasn't aware of that form of moniker construction
(ie with the username / password embedded) and on
an XP-to-2k3 link it doesn't seem to work. Is it a
Vista / 2k8 extension? Obviously, above, I was relying
on the fact that the default default namespace (as opposed
to the DEFAULT namespace ;) ) is root\cimv2.
More information about the Python-list