我需要使用 C# 和 sc.exe 实用程序创建服务
当我尝试执行
C:\Windows\system32\sc.exe create ServiceName binPath= D:\work\ServiceExe.exe ,

它工作正常。
但是当我尝试执行
Process.Start(@"C:\Windows\system32\sc.exe create ServiceName binPath= D:\work\ServiceExe.exe");
我有一个异常(exception),即 系统找不到指定的文件

它可以是什么?
文件存在,重新安装前删除服务。

最佳答案

您应该使用 Process.Start 的另一个重载,它将参数作为单独的参数。

Process.Start(@"C:\Windows\system32\sc.exe", "create ServiceName binPath= D:\work\ServiceExe.exe")

关于c# - 使用 C# 创建服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5881901/

10-15 08:47