Re: [Tutor] Communicating with Win2000 runas.exe

2006-08-18 Thread Tim Golden
[Tim Golden]
|  [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. 

[Barnaby Scott]
| 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):

Excellent! I'm glad it turned out to be so easy, and thanks for
posting the code and the link.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Communicating with Win2000 runas.exe

2006-08-17 Thread Barnaby Scott
I have a problem which I was hoping that Python could solve for me, but
I have become stuck for days now after only 2 lines of code.

My son has a Microsoft game on a shared family computer, which Microsoft
in its infinite wisdom requires you to run as 'administrator'. Call me
old-fashioned but I don't want to promote an 8 year-old to administrator
just so he can run his game!

Enter 'runas.exe'...

However, because we are on Windows 2000, runas does not allow you to
save a password - it has to be entered every time: not much further forward.

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!

Sure enough, this brings up a prompt asking for the administrator's
password, but I can't get anything to work in terms of getting the 
script to provide the password.

Am I barking up the wrong tree here? Any clues would be gratefully
received. (Even if I do get this to work, my next trick is to hide the
password from any prying eyes looking at the script...)

Thanks

Barnaby Scott


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Communicating with Win2000 runas.exe

2006-08-17 Thread Tim Golden
[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


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Communicating with Win2000 runas.exe

2006-08-17 Thread Barnaby Scott
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
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor