如何使用Inno Setup在具有管理员权限的情况下使程序在启动时运行? [英] How to make the program run on startup with admin permission with Inno Setup?

查看:73
本文介绍了如何使用Inno Setup在具有管理员权限的情况下使程序在启动时运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照Inno Setup KB:在启动"(或自动启动")组中创建快捷方式.

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

我有以下几行:

[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.

我该怎么办?

推荐答案

如果我正确理解了您的问题,则您的应用程序需要以提升的特权运行.

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.

改为安排具有最高特权"的登录时"任务.
请参见如何在Windows下以用户登录名运行具有管理员权限的程序?

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

有关通过Inno Setup计划任务的信息,请参见如何使用Inno Setup添加计划的任务.

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

这篇关于如何使用Inno Setup在具有管理员权限的情况下使程序在启动时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆