Popular Python recipes tagged "login"http://code.activestate.com/recipes/langs/python/tags/login/2010-12-23T00:10:08-08:00ActiveState Code RecipesSubprocess As Another User (Python)
2010-12-23T00:10:08-08:00Eric Pruitthttp://code.activestate.com/recipes/users/4170757/http://code.activestate.com/recipes/577495-subprocess-as-another-user/
<p style="color: grey">
Python
recipe 577495
by <a href="/recipes/users/4170757/">Eric Pruitt</a>
(<a href="/recipes/tags/login/">login</a>, <a href="/recipes/tags/subprocess/">subprocess</a>, <a href="/recipes/tags/user/">user</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 3.
</p>
<p>Modifies the subprocess module and supplies a new class, LoginSTARTUPINFO, to launch processes as another user on Windows. Requires the pywin32 libraries, but the system ../lib/subprocess.py does not need to be modified.</p>
<pre class="prettyprint"><code>>>> import subprocesswin32 as subprocess
>>> sysuser = LoginSTARTUPINFO("username", "machine", "passwd123")
>>> stdout, stderr = subprocess.Popen("cmd.exe", stdout=subprocess.PIPE,
... startupinfo=sysuser).communicate()
</code></pre>