我试图为一个用例创建服务。 经过大量 POC 之后,我了解到我们不能在服务名称中包含连字符。
我尝试使用以下命令创建服务: sc.exe 创建 rahul-kumar binpath=“C:\Windows\System32\Windows\PowerShellv1.0powershell.exe”
我能够使用连字符创建服务。
有人可以向我证实这一点吗? 非常感谢您的帮助
不可以,服务名称可以包含连字符。
问题是 powershell 可执行文件的路径不正确:
C:\Windows\System32\Windows\PowerShell\v1.0\powershell.exe
这不是 System32\Windows\PowerShell 1.0,而是 System32\WindowsPowerShell 1.0
您需要删除该服务并使用此命令创建一个新服务(powershell 的固定路径):
sc.exe create rahul-kumar binpath= "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"