修改 Windows MSI 安装程序中的服务控制权限
所以现在我正在尝试使用以下命令更改 Windows 服务的权限: sc sdset SERVICENAME PERMISSIONS
我已将其作为操作放置在 MSI 安装程序中,并且似乎执行得很好。但是,sc 需要管理员 privlidges 来设置权限,而我似乎无法在 MSI 安装程序中找到执行此操作的方法。我尝试使用命令 runas /user:administrator 但不幸的是,这在安装程序将运行的计算机上可能会有所不同。
有什么建议吗?
So right now I'm trying to change permissions on a windows service by using the command: sc sdset SERVICENAME PERMISSIONS
I have placed this in an MSI installer as an action and it seems to execute fine. However, sc requires administrator privlidges to set the permissions and I cannot seem to find a way to do that within the MSI installer. I tried using the command runas /user:administrator but unfortunatley this could be different on the machines the installer is going to run on.
Any tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要以完全权限运行自定义操作,您可以将其标记为延迟而不进行模拟。每个设置创作工具的执行方式都不同,因此如果您需要更多详细信息,则需要更具体地了解您所使用的工具。
基本设置为:
这样您的自定义操作将在具有完全权限的本地系统帐户。
To run a custom action with full privileges you can mark it as deferred with no impersonation. This is done differently in each setup authoring tool, so you need to be more specific about what you are using if you want more details.
The basic settings are:
This way your custom action will run under the local SYSTEM account with full privileges.
从 Windows Installer 5.0 开始,您还可以使用 MsiLockPermissionsEx 表。例如,在 WiX 中,它看起来像这样:
这为我创建了一个具有正确权限的服务。它还应该照顾管理员权限,尽管我还没有测试过仅使用该服务的独立安装程序。另请参阅:
Starting with Windows Installer 5.0, you can also use the MsiLockPermissionsEx table. In WiX that would for example look like this:
This creates a service with the correct permissions for me. It should also take care of admin privileges, though I haven't tested a standalone installer with just the service. See also: