如何设置 Windows 服务的 DACL 以便普通用户可以启动/停止该服务

How to set DACL of a Windows service so that a normal user can start / stop the service

我有一个 Windows 服务应用程序,我正在使用 install shield 构建其安装程序。安装时如何设置服务的DACL? 我知道我可以在安装后执行 "sc sdset"。但我想将提升的权限设置为安装过程的一部分。有办法吗?

我假设您已经正确地安装了您的服务。以下资源可能有助于确认:Using InstallShield to Create an Installation that Installs Windows Services as well as InstallShield help library: Installing, Controlling, and Configuring Windows Services.

我不确定是否可以使用 IDE 来设置 DACL 设置,您可能可以快速浏览此选项,但我认为它不存在并且您想手动执行此操作。在这种情况下,我能看到的最简单的解决方案是创建自定义操作 (CA) 并将 "In-Script Execution" 设置为“Deferred Execution in System Context". By doing this you set elevated execution of this CA. Schedule this CA somewhere in Execution Sequence (Not in UI sequence), probably right after "InstallServices". Now you have a few options what this CA should do. For example you may just use command line "sc" to set desirable permissions. You may also write VBScript CA to do the same. You may write installation helper dll with would do registration for you. All in your hands. More on those option over there.

安装 运行 之后,此命令作为 post 安装过程的一部分: SUBINACL /SERVICE /GRANT=S-1-5-32-545=TO

这为 windows 服务提供了管理员权限。