Popular recipes by Ofer Helman http://code.activestate.com/recipes/users/4179914/2011-11-18T11:54:42-08:00ActiveState Code RecipesExecute remote commands on windows like psexec (Python)
2011-11-18T11:54:42-08:00Ofer Helmanhttp://code.activestate.com/recipes/users/4179914/http://code.activestate.com/recipes/577945-execute-remote-commands-on-windows-like-psexec/
<p style="color: grey">
Python
recipe 577945
by <a href="/recipes/users/4179914/">Ofer Helman</a>
(<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/remote/">remote</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 4.
</p>
<p>This code attempts to implement psexec in python code, using wmi.
As part of a project of mine I had to run remote commands on remote Windows machines from other Windows machine. At first I used psexec for that with subprocess.Popen.
The reason in this code for creating .bat files and running them remotely is because complicated commands do not run properly with Win32_Process.Create</p>
<p>In this code I used this code: <a href="http://code.activestate.com/recipes/442521/history/3/" rel="nofollow">http://code.activestate.com/recipes/442521/history/3/</a></p>
<p>required installations:</p>
<p>pywin32 - <a href="http://sourceforge.net/projects/pywin32/files/pywin32/Build216/" rel="nofollow">http://sourceforge.net/projects/pywin32/files/pywin32/Build216/</a></p>
<p>wmi - <a href="http://timgolden.me.uk/python/downloads/" rel="nofollow">http://timgolden.me.uk/python/downloads/</a></p>