In the call to OpenProcessToken, you'll need to specify TOKEN_QUERY also.

     Roger

"Gremlin" <grem...@armarize.com> wrote in message 
news:7C1FF6262D1C41509DEDE93ABBA01CFC@BELLO...
> Hello.
>
>
>
> I want to adapt the following technique into python:
> http://blogs.msdn.com/b/aaron_margosis/archive/2009/06/06/faq-how-do-i-start
> -a-program-as-the-desktop-user-from-an-elevated-app.aspx
>
> So I started with the following code:
>
>
>
> import win32security
>
> import win32process
>
>
>
> process = win32process.GetCurrentProcess()
>
> token = win32security.OpenProcessToken(process,
> win32security.TOKEN_ADJUST_PRIVILEGES)
>
> privilege_luid = win32security.LookupPrivilegeValue(None,
> win32security.SE_INCREASE_QUOTA_NAME)
>
> privilege = [(privilege_luid, win32security.SE_PRIVILEGE_ENABLED)]
>
> win32security.AdjustTokenPrivileges(token, 0, privilege)
>
>
>
> But it fails with the error number 5 (Access denied) once
> "AdjustTokenPrivileges" has been executed. That would be obvious if I had
> not started python as admin. (Properties -> Start as admin) Also the process
> token is another one (at least the integer of token.handle is another one)
> if started as non-elevated. I have no idea why this is happening. I do have
> the appropriate permissions and the code should be correct. Can anyone help
> me? (Btw: My OS is Windows7 Pro 64bit and I'm not a standard user.)
>
>
>
> Regards,
>
> Johannes
>
>
>
>


--------------------------------------------------------------------------------


> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
> 



_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to