[python-win32] Running remote command (like psexec.exe)

Tim Golden tim.golden at viacom-outdoor.co.uk
Tue Aug 2 16:49:28 CEST 2005


[Boucher, Eric]
| 
| Hi,
| 
| I wanted to know if it's possible to execute remote command from one
| computer to another, a little bit like the utility "psexec.exe" from
| sysinternals (www.systinternals.com), with python code 
| (without calling
| os.system("psexec ...")). I want to execute a DOS command on 
| a group of
| computer. I wander if it's possible with python. Maybe should 
| I use Corba
| (which is more complicated to me) or some COM that I will 
| have to put on
| each computer? Is it possible without installing anything on 
| the remote
| computer?

You should be able to do it using WMI:

http://timgolden.me.uk/python/wmi_cookbook.html#create_destroy_notepad

In theory, there are restrictions on what you can run on
a remote computer -- specifically, the notebook example should
fail -- and I think that XP / 2k3 have added more restrictive 
security. But try it for the process you have in mind to see if it works.

In the WMI () constructor, pass the name of the remote computer:

c = wmi.WMI ("other_computer")

This doesn't require anything on the remote PC except WMI, which
is standard with Windows from Win2K upwards. If this doesn't work,
you have several options involving running some Python process
on the other machine: Pyro, XMLRPC, Corba, simple socket servers,
and many more.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the Python-win32 mailing list