[Tutor] Communicating with Win2000 runas.exe

Barnaby Scott bds at waywood.co.uk
Fri Aug 18 06:08:25 CEST 2006


Tim Golden wrote:
> [Barnaby Scott]
> 
> | So I'm thinking along these lines:
> | 
> | import subprocess
> | sp = subprocess.Popen(r'C:\WINNT\SYSTEM32\runas.exe 
> | /user:administrator
> | C:\Program Files\Microsoft Games\Age of Mythology\aom.exe')
> | #some sort of code to send the password here...
> | #help!
> 
> I *think* -- and I'm happy to be wrong -- that there's
> no way you're going to get that password in there. One
> place to start looking might be:
> 
> pywinauto - http://pywinauto.pbwiki.com/
> 
> which lets you automate Windows in general; don't know
> how much use it'll be here. 
> 
> Alternatively, look into the pywin32 package, and in 
> particular at the win32security functions which let you 
> impersonate another user. They're not trivial to use, 
> but their use has been explained a few times over the 
> years I think. Mostly by Roger Upole who wrote most if 
> not all of the Python bindings.
> 
> Here's a post which looks useful; you'll have to hunt
> around for others:
> 
> http://groups.google.com/group/comp.lang.python/msg/6bbefb9d4d45d253
> 
> I suggest you ask this question again on the main
> python / python-win32 lists; it's a bit too platform-specific
> for the tutor list, I would say.
> 
> TJG

Thanks for your tips. In fact the first link you gave put me onto 
Sendkeys (http://www.rutherfurd.net/python/sendkeys/), which is a 
prerequisite for pywinauto. In the end that was all I needed. In case 
anyone else is interested here is my code now (with SendKeys installed):


import subprocess, SendKeys

subprocess.Popen(r'C:\WINNT\system32\runas.exe /user:administrator 
"C:\Program Files\Microsoft Games\Age of Mythology\aom.exe"')

SendKeys.SendKeys('{PAUSE 1}MyAdministratorPassword{ENTER}')


Worth knowing about - might be quite useful for all sorts of things, 
however 'quick and dirty' it feels as a technique!

Thanks again

BDS


More information about the Tutor mailing list