使用C#创建服务 [英] Create a Service using C#
本文介绍了使用C#创建服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用C#和 sc.exe 实用工具创建服务当我尝试执行
I need to create a service using C# and sc.exe utility when i try to execute
C:\ Windows \ system32 \ sc.exe创建ServiceName binPath = D:\ work \ ServiceExe.exe
,
它工作正常.但是当我尝试执行
it works fine. But when i try to execute
Process.Start(@"C:\ Windows \ system32 \ sc.exe创建ServiceName binPath = D:\ work \ ServiceExe.exe");
我有一个例外,系统找不到指定的文件.
那会是什么?文件已存在,服务已删除,然后重新安装.
What can it be? File exists, Service removing before re-install.
推荐答案
您应该使用 Process.Start
的另一个重载,该重载将参数作为单独的参数.
You should use another overload of Process.Start
which takes arguments as a separate parameter.
Process.Start(@"C:\Windows\system32\sc.exe", "create ServiceName binPath= D:\work\ServiceExe.exe")
这篇关于使用C#创建服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文