Skip to content
⌘ NSIS Forum Archive

nsExec with Admin rights

3 posts

RainerHH#

nsExec with Admin rights

I use nsExec::ExecToStack /OEM
to execute a command line instruction.

But the program refuses to run because it does not have administrator privileges.

What can I do?
Anders#
Ideally you should use "RequestExecutionLevel Admin" to make the installer elevate if you intend to run any child processes elevated.

nsExec can't elevate because its reason to exist is to handle stdout and to elevate it would have to call ShellExecuteEx and then you lose control over stdout. It could theoretically be done by using a extra helper process but the plug-in does not currently support that.

Your best bet is to use ExecShellWait with the "runas" verb. You lose control over stdout and elevation will NOT work if UAC has been turned off and it might not elevate on < Vista.