Windows Services
From MgmtWiki
Full Title or Meme
Best practices on using Windows Services.
Solutions
- How to Allow Non-Admin Users to Start/Stop Windows Service?
- The Windows User need permission to run a service with that user account.
- First enable Windows Group Policy editor.
PowerShell script
a function for PowerShell that changes the username, password, and restarts a service on a remote computer (you can use localhost if you want to change the local server). I've used this for monthly service account password resets on hundreds of servers.
You can find a copy of the original at http://www.send4help.net/change-remote-windows-service-credentials-password-powershel-495
It also waits until the service is fully stopped to try to start it again, unlike one of the other answers.
Function Set-ServiceAcctCreds([string]$strCompName,[string]$strServiceName,[string]$newAcct,[string]$newPass){ $filter = 'Name=' + "'" + $strServiceName + "'" + '' $service = Get-WMIObject -ComputerName $strCompName -namespace "root\cimv2" -class Win32_Service -Filter $filter $service.Change($null,$null,$null,$null,$null,$null,$newAcct,$newPass) $service.StopService() while ($service.Started){ sleep 2 $service = Get-WMIObject -ComputerName $strCompName -namespace "root\cimv2" -class Win32_Service -Filter $filter } $service.StartService() }