Using SC.exe to set service credentials password fails

后端 未结 8 1081
野性不改
野性不改 2020-12-10 14:05

I know this question has been asked in the past, but a satisfactory answer has not been provided.

I am using the SC command to config the credentials for a service.<

8条回答
  •  隐瞒了意图╮
    2020-12-10 14:36

    Before restarting services, you should grant your user permission to logon as a service. Unfortunately, no way to do it from command line with default windows tools, but you can use small additional util ntright.exe from Windows Server 2003 Resource Kit Tools.

    Download it from https://www.microsoft.com/en-us/download/details.aspx?id=17657

    After installation you'll get a lot of tools in C:\Program Files (x86)\Windows Resource Kits\Tools (or in Program Files on 32bit machine).

    You need ntrights.exe. You can copy it and run from any place on another host.

    To grant your user required permission, you should add to your script:

    ntrights.exe +r SeServiceLogonRight -u "%DOMAIN%\%USER%"
    

    After that you can successfully restart services with a new user. Also there is an option to run ntrights.exe on remote host:

    ntrights.exe +r SeServiceLogonRight -u "%DOMAIN%\%USER%" -m %HOSTNAME%
    

    This tool helps me very much when I need reconfigure a lot of hosts remotely.

提交回复
热议问题