我有一个无限循环的PowerShell(用于测试目的)脚本,我希望将其作为服务在Windows Server 2008 R2(标准版)中运行。
我正在使用以下命令创建Windows服务,
sc.exe create "My PS1Service" binPath= "powershell.exe -NoLogo -Path D:\TEST\test.ps1"
结果是 [SC] CreateService SUCCESS
但当我尝试运行服务My PS1Service
时,它返回以下错误
Windows Could not srart the My PS1Service service on Local
Computer
Error 1053: The service did not respond to the start or control
request in a family
有人可以帮忙吗!!!
get-help New-Service
。同时请指定powershell.exe
的完整路径。 - arco444System.ServiceProcess.ServiceBase
继承。你在test.ps1中做了类似的事情吗? - Mike Zboray