Search code examples
pythonwindowssubprocessrunas

Python subprocess.Popen as different user on Windows


What is the best manner of launching a subprocess as a different user in Python on Windows? Preferably XP and up, but if it works only on Vista and 7, I can live with that too.


Solution

  • I am not sure if you can do this with the standard python libraries. However, the pywin32 package has a win32process.CreateProcessAsUser function which may be what you need.