Share This Post

Scripting Service Account Changes

I recently had a situation where I needed to script the creation of a Windows service and specify a domain user/password to run the service.  The main struggle was getting the service to grant the user “Log On As Service” rights, which wasn’t being automatically completed with the SC.exe tool.  To accomplish this feat, the NTRights.exe utility from the Windows Server 2003 Resource Kit was needed, and will be needed for the below script!

sc.exe create "My Service" type= own start= auto binpath= "C:\Program Files\Product\MyApp.exe"
sc.exe config "My Service" obj= "domain\username" password= "thePassword" type= own
"ntrights.exe" -u domain\username +r SeServiceLogonRight
sc.exe start "My Service"

 

Share This Post

Hello and thanks for reading my blog (http://t3chn1ck.wordpress.com)! My hope is that information I post is useful to others! If you found that a solution did help you, or if you have questions, feel free to drop a comment on the post. I primarily blog on my IT experiences with ConfigMgr and desktop engineering. I am a 10 year, seasoned professional with ConfigMgr and systems management. I co-facilitate and present for the local user group in Denver, am an active blogger on topics for ConfigMgr and systems management techniques, involved in forums for Microsoft and MyITForum, and have been a speaker for events such as BDNA's SCCM Guru Webcast Series (March 2012), the Microsoft Management Summit (April 2013), and BDNA's Microsoft Master Webcast Series (Jan. 2014).

Leave a Reply