Execute a Execwait in NSIS with administrative privileges
Asked Answered
C

1

8

I want to execute ExecWait in NSIS with admin privileges, I was unable to find any documentation on this issue.

Cornetcy answered 22/7, 2012 at 18:49 Comment(0)
P
7

Generally I would recommend that the whole installer should run elevated in a case like this, it makes it clear to the user up-front that elevation is required.

If you cannot do this then you should make sure that the program you want to run requests administrator rights. For this to work you need to launch the program with ExecShell.

If that program does not requests administrator rights you basically have two options:

  • Use ExecShell with the "runas" verb and hope for the best (Fails if the user is not a member of the administrators group, UAC is off or on < Vista)
  • Write a small launcher application that requests administrator rights and then launches the real program.
Punjabi answered 22/7, 2012 at 20:55 Comment(4)
I tried the second option (Write a small launcher with admin request) ... and it didn't work.Refectory
@jing: Provide some more details or ask it as a question maybe?Punjabi
@Anders: I did what you proposed: Parent NSIS package requested only user privileges (RequestExecutionLevel user), child NSIS package requested admin privileges (RequestExecutionLevel admin). I can launch child from OS. But parent NSIS package fails to launch child using ExecWait. Parent NSIS package launches child one only after right-click "Run As Administrator". Anyway I don't expect such process can work correctly.Refectory
You cannot use ExecWait, you have to use ExecShell because UAC is only hooked into the shell and not as deep as CreateProcess.Punjabi

© 2022 - 2024 — McMap. All rights reserved.