Executing a remote process via WMI in Win32.

Sean null-spam at tfh.ca
Mon Jul 7 20:20:59 CEST 2003

I can connect to a machine remotely with no problems but I'm having trouble
trying to create a process remotely.  Initially this was a perl and VB
script which I'm converting to python.  Its entire purpose is to start a
process remotely.  The problem initially was that the perl script could not
'see' any mapped drives as it would alway return 'access denied' so I'm
trying to not only rewrite the script but fix this problem and my idea was
to connect with the Administrator account.

Now the following script sort of works.  I can get the set of running
processes but it dies out when I try to create one.

## being ##
import win32com.client
wmi = win32com.client.Dispatch('wbemscripting.swbemlocator')
remote_machine =

process = remote_machine.InstancesOf("Win32_Process")
for proc in process:
    size = int(proc.WorkingSetSize)/1024
    print proc.Caption, size,"kb"
# test to see if we can 'see' what's on a mapped drive.
# doesn't seem to go.
process.Create("cmd.exe /K dir w:\\")
## END ##

The script will print out all the processes fine but once it get's to
'Create' it dies out with and error message I don't understand.

Traceback (most recent call last):
  File "C:\Documents and Settings\scody\test.py", line 14, in ?
    process.Create("cmd.exe /K dir w:\\")
  File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 460,
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: InstancesOf.Create

The process method should only have the one parameter as defined at:

I just tried using the 'Terminate' process but that didn't work either....

So I'm going to assume that the WMI objects are not instantiated as python
classes (hence why the methods are not working).  Am I completely off base
here (meaning it is a syntax problem)?

Any suggestions or pointers to the right direction would be creately

(ps. remove -spam to email me).

More information about the Python-list mailing list