Hello,
I've passed some time reading the MS coding guide for Vista
http://msdn.microsoft.com/en-us/library/bb756973.aspx
It explains that an app requiring administrator rights (modify HKLM,
write in C:\Windows\, etc.) will always return "Access denied" or ask
the user for UAC if it's launched with the appropriate manifest or with
"runas".
You can personalize the UAC prompt by a short description of your
program and an icon.
In short, if your user app does something like that, rewrite it using a
service.
Mark Hammond a écrit :
With Vista (XP works fine), when using SetValueEx in a script ran by an
administrator I get "Access Denied". I know that's it's due to UAC so
does someone know how to do a 'sudo' when using something else than
CreateProcess ?
The short version of my understanding of Vista and UAC: Firstly, an
existing process can not be elevated - once you are running, you are out of
luck - your option is, basically, re-execute yourself requesting elevation
and have the new process retry the operation (the exception is when you are
using a COM object - in which case you can ask for an "elevated" COM object
- but that is rare, so I'm treating it as the exception :) If you want to
reexecute yourself, IIUC you are limited to calling ShellExecute(Ex), with
the "verb" set to "runas" - which can be a PITA, but I'm not aware of other
options. My current best guess for when you might *need* to do this if is
win32com.shell.IsUserAnAdmin() returns true (which needs pywin32-211, which
I promise is in the process of being tested right now :)
As Tim said though, please read MSDN and all other references you can find,
and please correct me if I'm wrong/mistaken/confused/etc for everyone elses
benefit...
Cheers,
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32