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.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
I ended up augmenting subprocess:
The following code launches
cmd.exe
as userusername
: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.
Another option is to popen not the desired process but
runas ...
command. Note that theRun As
service should be enabled and running.