<div dir="ltr"><div>Perhaps ShellExecuteEx will do what you are wishing for?<br></div><div>I found a good formula for starting a process as an administrator and it is packaged in <br><a href="https://github.com/salt-bevy/salt-bevy/blob/master/configure_machine/sudo.py">a small module</a> tries to emulate a "sudo" command. You might look at the code around line 76.</div><div><br></div><div>Starting a subprocess in Windows is somewhat of a black art, I fear. <br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 18, 2019 at 7:16 PM Kuree Kafir <<a href="mailto:kuree.offsec@gmail.com">kuree.offsec@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hello,</div><div><br></div><div>I am trying to implement something similar to the runas /netonly command in python. <br></div><div><br></div><div>handle = win32security.LogonUser(userName, domain, password, win32con.LOGON32_LOGON_NEW_CREDENTIALS, win32con.LOGON32_PROVIDER_DEFAULT)<br>win32security.ImpersonateLoggedOnUser(handle)</div><div><br></div><div>These two commands succeed, and I can see the credentials in memory, but when I attempt to call something like os.system("cmd.exe") and attempt to authenticate, the security context previous created is not presented, and authentication fails. <br></div><div><br></div><div>How do I correctly call CreateProcess using the impersonation session that I just created?</div><div><br></div><div>kuree<br></div></div></div>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org" target="_blank">python-win32@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-win32" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-win32</a><br>
</blockquote></div>