Scripting Service Account Changes

Posted on

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"

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s