1

By following the Inno Setup KB: Create shortcuts in the Startup (or Autostart) group.

I have these lines:

[Setup]
...
PrivilegesRequired=admin

[Icons]
Name: "{commonstartup}\app"; Filename: "app.exe"

However on startup, it says "access denied". Looks like it is not run as administrator.

What should I do?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
jamesdeath123
  • 4,268
  • 11
  • 52
  • 93

1 Answers1

2

If I understand your question correctly, your application requires to be run with elevated privileges.

You cannot use the ancient "Startup" folder method to run applications with elevated privileges.

Instead schedule an "at logon" task with "highest privileges".
See How to run a program with administrator privileges on user login under Windows?

For scheduling a task from Inno Setup, see How to add a scheduled task with Inno Setup.

You will need the /RL highest and /SC onlogon switches of the schtasks command.

[Run]
Filename: "schtasks"; \
    Parameters: "/Create /F /RL highest /SC onlogon /TR ""app.exe"" /TN ""Run app as admin on logon"""; \
    Flags: runhidden
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992