How to change user credentials of windows service from command line?
To configure this, Navigate to Admin >> Settings >> General Settinngs. In the UI that opens, select Password Reset from the options on the left hand side. Click the checkbox Wait for a specified time period (in seconds) between stopping and starting the services.
Try this: Navigate to c:\windows\system32. Enter the following command: runas /user:computer_name\account_name explorer.exe.
First of all, credentials for service accounts are stored in the local registry, as what's called "LSA Secrets" in the registry key HKEY_LOCAL_MACHINE/Security/Policy/Secrets. Because the service needs to read the actual password to login as the service account, that password is in the registry in clear-text.
sc.exe config "Service Name" obj= "DOMAIN\User" password= "password" type= own
See Shortcut Setting Log-On Credentials for Windows Services » jonathanmalek.com.
@MattT points out that on Windows Server 2008R2 you have to add type= own
, but prior to that version it isn't necessary.
In PowerShell 3+, you can avoid escaping the arguments with the stop-parsing symbol: --%
sc.exe --% config "Service Name" obj= "DOMAIN\User" password= "password" type= own
I simply called WMI from powershell to do this.
$Svc = Get-WmiObject win32_service -filter "name='ServiceName'" $Svc.Change($Null, $Null, $Null, $Null, $Null, $Null, "User", "Password")
Don't forget to restart the service afterwards:
Stop-Service -Name 'ServiceName' Start-Service -Name 'ServiceName'
For more fun with WMI and services, see Win32_Service Class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With