How to make the program run on startup with admin permission with Inno Setup?

帅比萌擦擦* 提交于 2019-12-23 03:02:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!