我很确定答案很简单,但就在这里;
我正在使用 TopShelf 安装我的服务,我可以从命令行成功安装和运行它
MyExecutable.Daemon 安装 MyExecutable.Daemon 启动
这很好,但它必须在服务中,但我没有尝试;
sc create "MyExecutable.Daemon" binPath= "C:\'Program Files (x86)'\MyExecutable.Daemon.exe" DisplayName= "MyExecutable.Daemon" start= auto
但是得到了
Set-Content : A positional parameter cannot be found that accepts argument 'binpath='.
At line:1 char:1
+ sc create MyExecutable.Daemon binpath= "C:\'Program Files (x86)'\...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Content], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand
所以我被困在这里了。我在这里缺少什么?
最佳答案
sc
在 powershell 中是 set-Content
cmdlet 的别名,使用 sc.exe
代替。
试试这个(未测试)
sc.exe create "MyExecutable.Daemon" binPath="C:\'Program Files (x86)'\MyExecutable.Daemon.exe" DisplayName="MyExecutable.Daemon" start=auto
关于windows - 使用 Topshelf 安装后在服务下看不到我的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18893345/