【发布时间】:2013-08-15 00:53:05
【问题描述】:
我想知道CreateService() 或ChangeServiceConfig() 是否为远程主机上的服务提供了托管等效功能?
Service Installer 类似乎只在本地运行。
【问题讨论】:
我想知道CreateService() 或ChangeServiceConfig() 是否为远程主机上的服务提供了托管等效功能?
Service Installer 类似乎只在本地运行。
【问题讨论】:
我建议查看这个现有问题:Installing a windows service on a remote machine using a given username。
在这个答案中,他们提到使用“SC.exe”。这是 Windows 中的一个工具,可让您“create and start a service”。您应该能够使用 System.Diagnostics 中的 Process 类轻松运行此程序。例如,这里是基于Patrick McDonald 示例的代码,它将在计算机“远程计算机”上启动 NewServ.exe。
Process process = new Process();
process.Start(@"C:\Windows\System32\SC.exe", @"\\remotecomputer create newservice binpath= C:\Windows\System32\Newserv.exe start= auto obj= DOMAIN\username password= pwd");
如果这不起作用,那么您应该能够创建自己的安装程序,将其复制到远程计算机,然后远程启动该过程。有关详细信息,请参阅此问题:How to execute a process on a remote machine, in c#
【讨论】: