0

I create an installer by Inno setup. MyPro.exe installed by the installer should run as administrator in Win7. The following is the important part of the script. However, MyPro.exe still can not run as administrator and it can not write its profile in \System. Can you tell me which is wrong?

[Setup]
PrivilegesRequired=admin

[Icons]
Name: {group}\MyPro; Filename: {app}\MyPro.exe; Flags:

[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"; ValueType: String; ValueName: "{app}\MyPro.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletekeyifempty uninsdeletevalue; MinVersion: 0,6.1

Root: "HKCU"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: String; ValueName: "{app}\MyPro.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletevalue; MinVersion: 0,6.1
TLama
  • 75,147
  • 17
  • 214
  • 392
r766r766
  • 1
  • 3
  • That's not how it works. You need to add into your application manifest that you want to run your application as administrator if that's your aim. See e.g. [`this Q&A`](http://stackoverflow.com/q/11773921/960757) for reason and [`this Q&A`](http://stackoverflow.com/q/707497/960757) for possible solution. – TLama Jun 11 '14 at 10:23
  • But if it is not really your app and you cannot add the manifest, and you have to use Compatibility Flag, and you own the 64bit system then you can try to change the first Registry Entry and split it for 64bit and 32bit systems. `Root: "HKLM64"; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"; ValueType: String; ValueName: "{app}\MyPro.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletekeyifempty uninsdeletevalue; MinVersion: 0,6.1; Check: IsWin64` for 64bit systems and `"HKLM"; [...]MinVersion: 0,6.1; Check: not IsWin64` for 32bit systems. – RobeN Jun 11 '14 at 11:10
  • Thank you, TLama. MyPro is a MFC project and manifest is easy to added in VC as your suggestion link http://stackoverflow.com/questions/707497/set-app-to-require-elevation. I will try the way first. – r766r766 Jun 11 '14 at 14:39
  • Also note that apps that run as admin should be the exception, not the rule. While there are some legitimate reasons for doing it, you should assume by default that if something isn't working without admin permissions, you're doing it wrong. – Miral Jun 11 '14 at 21:57

0 Answers0