[python-win32] Is there a Python win32 RunAs equivalent where youcan send a password?

R. Alan Monroe amonroe at columbus.rr.com
Thu Mar 18 16:21:19 EST 2004


> used a COM object called sfImpersonator to some success.  You probably
> *could* spawn a cmd file and use popen to send the password, but it
> would have to be a hack.

What's the trick to using the popen approach? (I've temporarily given
up on the windows api method) Everything I've tried gives me IOError:
[Errno 22] Invalid argument when I tried to write() to the child's
stdin, or the main program just exits killing any children.

I've tried this with and without the "cmd" at the front, wrapping it
in a cmd file, etc.


pin, pout  = os.popen2( 'cmd /C runas /user:tco\pyadmin  "dumpsec /computer=\\\\ess /rpt=allsharedirs /showexcdirs \
/outfile=ess-shares.tsv /saveas=tsv" ')
print pin, pout
pin.write('xxxxxx\n')
pin.flush()


Alan




More information about the Python-win32 mailing list