使用C#创建服务

E-M*_*Max 4 .net c# windows-services

我尝试执行时需要使用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");

我有一个例外,即系统找不到指定的文件.

它能是什么?文件存在,重新安装前删除服务.

Fra*_*čik 9

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

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