[英]Installing a windows service on remote machine using given username
在远程计算机上安装用C#编写的Windows服务(以标准方式)的最佳方法是什么?我需要提供应该运行的用户名和密码?
我将从MSBuild运行它作为集成测试的一部分。
编辑:我没有msi,我不想创建一个。
您可以使用SC命令。
sc.exe \\\\remotecomputer create newservice binpath= C:\\Windows\\System32\\Newserv.exe start= auto obj= DOMAIN\\username password= pwd
(注意等号后的空格很重要)
Creates a service entry in the registry and Service Database.
SYNTAX:
sc create [service name] [binPath= ] <option1> <option2>...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec>
(default = own)
start= <boot|system|auto|demand|disabled>
(default = demand)
error= <normal|severe|critical|ignore>
(default = normal)
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
(default = LocalSystem)
DisplayName= <display name>
password= <password>
从Powershell调用的WMI调用的Installutil是一种方法。
您可能值得查看我编写的实用程序,该实用程序允许您在本地或远程计算机上安装/卸载/启动/停止Windows服务。 如果你有一个功能,你需要添加让我知道(评论/ github问题或PM,我很乐意)。
正如@Raj More所建议的,它使用从.NET调用的WMI。
我们曾经使用PsExec来做远程机器上的所有事情。 这时我看到了另一个名为PowerShell Remoting的解决方案,但还没试过自己。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.