【发布时间】:2016-04-11 22:41:37
【问题描述】:
使用sc命令我们可以查询、启动、停止windows服务。
例如:
sc query "windows service name"
sc config命令改变了服务的配置,但是不知道怎么用。
谁能告诉我如何为任何 Windows 服务设置用户名和密码?
【问题讨论】:
标签: windows service command-line
使用sc命令我们可以查询、启动、停止windows服务。
例如:
sc query "windows service name"
sc config命令改变了服务的配置,但是不知道怎么用。
谁能告诉我如何为任何 Windows 服务设置用户名和密码?
【问题讨论】:
标签: windows service command-line
这行得通:
sc.exe config "[servicename]" obj= "[.\username]" password= "[password]"
每个 [括号] 项目都替换为真正的参数。 (保留引号,但不要保留括号。)
请记住:
obj= "foo" 是正确的; obj="foo" 不是。【讨论】:
cmd.exe -e "sc config Service obj= user password= pass"
& sc.exe,不会有冲突。
sc.exe config "ServiceName" obj= "USER@DOMAIN" password= "MyPassword" TYPE= own (support.microsoft.com/en-us/kb/264663)
在 PowerShell 中,“sc”命令是 Set-Content cmdlet 的别名。您可以使用以下语法解决此问题:
sc.exe config Service obj= user password= pass
指定 .exe 扩展名,PowerShell 会绕过别名查找。
HTH
【讨论】: