使用 SC.exe 设置服务凭据密码失败 [英] Using SC.exe to set service credentials password fails
问题描述
我知道这个问题过去有人问过,但没有得到满意的答复.
I know this question has been asked in the past, but a satisfactory answer has not been provided.
我正在使用 SC 命令来配置服务的凭据.
I am using the SC command to config the credentials for a service.
SC.exe config "SERVICE NAME" obj= "domainuser" password= "password"
这成功完成,但是当我启动服务时,它失败了执行登录.
[NET START服务名称"
]
This completes successfully, but when I start the service, it fails
to perform the login.
[NET START "service name"
]
如果我仅从 services.msc 手动更新密码,那么当我启动服务时它工作正常.
If I manually update ONLY the password from the services.msc, then when I start the service it works fine.
我有数百台服务器来更新此更改发生在部署过程中,所以人工干预不是一种选择.
I have hundreds of servers to update this change occurs in the middle of a deployment, so manual intervention is NOT an option.
我尝试使用配置更新登录帐户,然后使用另一个配置命令更新密码.
I have tried using the config to update the login account and then another config command for the password.
对于所有帐户,SC.exe
对密码不起作用,Microsoft 也没有帮助.
From all accounts, the SC.exe
does not work for passwords and Microsoft has NO help.
想法?
推荐答案
除了 在进行更改之前停止服务,以及 授予用户作为服务登录的权限,我还必须添加type= own
参数,否则会失败:
Besides stopping the service before making the changes, and granting the user permission to logon as a service, I also had to add the type= own
parameter, otherwise it would fail with:
[SC] ChangeServiceConfig FAILED 87:
The parameter is incorrect
所以这是有效的命令:
SC.EXE config "ServiceName" type= own obj= "domainuser" password= "password"
它甚至可以在密码中使用特殊字符,因为我有双括号之间的密码.
It even worked with special characters in the password, given I had the password between double brackets.
这篇关于使用 SC.exe 设置服务凭据密码失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!