Inno Setup : How to set installer “Run As Administ

2020-05-26 12:18发布

问题:

In Inno Setup,

[Setup] 
PrivilegesRequired=admin 

is still can not Run the installer as Administrator, but I need to Launch my Program at last step of Inno Setup.

How can I do to set my Installer can Run as Administrator ?

回答1:

I have been having this same problem as well, it took me quite a bit of time to figure out that after you have set the PrivilegesRequired=admin you also need to add runascurrentuser to all the [Run]Flags.

[Setup]
PrivilegesRequired=admin

[Run]
Filename: "{app}\MyApp.exe"; Description: "{cm:LaunchProgram,MyApp}"; Flags: runascurrentuser nowait postinstall skipifsilent; Check: returnTrue()
Filename: "{app}\MyApp.exe"; Flags: runascurrentuser; Parameters: "-install -svcName ""MyApp"" -svcDesc ""MyApp"" -mainExe ""MyApp.exe""  "; Check: returnFalse()

I know you have probably already figured out the issue considering this question was asked over two years ago but I thought I would answer it anyway for others like myself who found this unanswered question but would have really liked to have seen an answer.



回答2:

My inno setup script is belowing,

#define MyAppName "MyApp"  
#define MyAppExeName "MyApp.exe"

[Setup]  
PrivilegesRequired=admin

[Run]   
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: runascurrentuser nowait postinstall skipifsilent


标签: inno-setup