gpt4 book ai didi

c# - 使用 C# 创建服务

转载 作者:太空狗 更新时间:2023-10-30 00:35:03 27 4
gpt4 key购买 nike

我需要使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com