Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: RunWithLogon UAC requires elevation 1932 prompt
When UAC is enabled and you attempt to use "RunWithLogon" to start a process that requires elevation, it will fail. The fact that the credentials passed to the function are for an administrator account does not matter. We know this seems counter-intuitive but this is just how UAC works.
So how so you explicitly elevate? Well normally you can use the ShellExecute function for creating a process that requires elevation. ShellExecute works because the shell sits in a much higher layer in the OS and consequently is able to take a dependency on elevation. Unfortunately there is no equivalent ShellExecuteWithLogon API!
;*************************************************************************** ;** ;** RunAs Bootstrapper - ShellExecuteWithLogon ;** ;*************************************************************************** ; Can be used by standard user to run a program requiring elevated admin privileges. ; This script must be compiled with the manifest 'asInvoker' ; The application you are launching must be compiled with the manifest 'HighestAvailable' or 'RequireAdministrator' appname = DirScript():'doadminstuff.exe' ; compiled with the manifest 'HighestAvailable' or 'RequireAdministrator' If param0 == 0 ; Relaunch this script using the filtered administrators token, and pass the commandline parameter 'Elevator' RunWithLogon(IntControl(1004, 0, 0, 0, 0), "Elevator", DirScript(), @NORMAL, @NOWAIT, "Guesswho", ".", "*topsecret*", 0) ElseIf param1 == "Elevator" ; Explicitly elevate to a full administrators token using ShellExecute ShellExecute(appname, "", FilePath(appname), @NORMAL, "") EndIfReference: http://blogs.msdn.com/b/cjacks/archive/2010/02/01/why-can-t-i-elevate-my-application-to-run-as-administrator-while-using-createprocesswithlogonw.aspx
http://www.sevenforums.com/tutorials/11949-elevated-program-shortcut-without-uac-prompt-create.html
Update: One drawback is that it requires that an Administrator sets up the task on the users workstation. Standard users cannot run scheduled tasks on demand. Makes sense for security though.
Article ID: W18319
Filename: RunWithLogon and UAC.txt
File Created: 2012:01:25:11:51:50
Last Updated: 2012:01:25:11:51:50