windows - 使用 Topshelf 安装后在服务下看不到我的服务

标签 windows powershell service installation topshelf

我很确定答案很简单,但就在这里;

我正在使用 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/

相关文章:

c# - 创建原始图形元素(无 Windows chrome)

powershell - 将选定项目从一个文件夹复制到新文件夹

android - 在某些设备中甚至使用 START_STICKY 后杀死应用程序后服务不会再次启动

powershell - 递归复制注册表子树,其中某些子项名称包含斜杠

从网络获取图像时出现 android.content.ActivityNotFoundException

android - HTC one - 应用程序每次都被杀死

windows - 如何创建行为类似于 .cmd/.bat 的文件扩展名?

php - 将标识符嵌入可执行文件以供下载

c++ - GetAsyncKeyState(VK_RETURN) 错误地评估为真

powershell - Docker PowerShell 镜像中的 Import-Module