View Single Post
Old 24th November 2015, 11:07   #8
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
Originally Posted by LoRd_MuldeR View Post
I was never suggesting to use the "runas" verb. If the "nested" (Un)Intstaller you try to launch requires elevation, as per its Manifest, ShellExecute(Ex) takes care of "elevation" automatically, i.e. it will trigger an UAC dialog, when the (Un)Intstaller gets launched from a non-elevated process. At the same time Exec and ExecWait would just fail (error #740), if you try to launch an (Un)Installer that requires elevation, as per its Manifest, from a non-elevated process. In the (rare) case that UAC is turned off, using Exec and ExecWait would work too. But otherwise they'd fail in that situation. At the same time, using an ShellExecute(Ex) solution should work in all cases.

I did not say that it does "start something elevated". What I actually said is that it allows for launching a process that requires elevation (as per its Manifest) from a non-elevated process. In that case Exec and ExecWait would just fail.
You did see that the code in the initial post already asks to be elevated right? If you are suggesting the he/she should use ShellExecute without the run as verb then that is even more crazy.

ShellExecuteEx works in all cases depending on your definition of working. It works differently depending on the system configuration which obviously is not a good thing. The OP wants to start a new process with administrator rights and a simple ShellExecuteEx is not enough because there are several corner cases you need to handle. Only a plugin with a specific RunAsAdmin type function can accomplish this in a satisfactory fashion.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote