Windows服务无法启动:无法在计算机“。”上启动服务[服务名称]。

时间:2020-06-22 09:27:24

标签: windows powershell windows-10 windows-services

我正在尝试使用以下代码创建Windows服务

$params = @{
  Name = "abc"
  BinaryPathName = "C:\Users\dell\Downloads\abinstall\abc.exe"
  DisplayName = "Windows Service"
  StartupType = "Automatic"
  Description = "This is a service."
}
New-Service @params

当我尝试在上述脚本上运行时,我得到这样的输出

Start-Service : Service 'Windows Service (abc)' cannot be started due to the following error: Cannot start
service abc on computer '.'.
At C:\Users\dell\Downloads\abinstall\start.ps1:14 char:4
+    Start-Service -Name "abc"
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service],
   ServiceCommandException
    + FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Commands.StartServiceCommand

I am running this in administrator powershell.
PS C:\Users\Public\k2agent-bkp>  Get-CimInstance win32_service | Where-Object Name -eq "abc"

ProcessId Name StartMode State   Status ExitCode
--------- ---- --------- -----   ------ --------
0         abc  Auto      Stopped OK     0

删除服务后,我尝试重新启动计算机。

我正在Windows 10工作站上运行它。

abc.exe是Java jar的包装器。

有人可以帮我吗?

谢谢。

0 个答案:

没有答案