问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/40030545/how-to-make-the-program-run-on-startup-with-admin-permission-with-inno-setup