Home > Shell Scripting, Windows > Changing a service’s startup policy via CLI

Changing a service’s startup policy via CLI


I recently needed to automate an installation of a service but ran into a problem that it was starting automatically by default (which we did not want).

So I found a simple CLI to change this behavior –

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\my-service-name /v Start /t REG_DWORD /d 3 /f

What it does is:

  1. Go to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\my-service-name entry in the registry
  2. Sets the value of Start (/v Start) to be the 32bit value (/t REG_DWORD) of 3 (/d 3)
  3. It overrides the current value if exists (/f)
All valid values are:
  • 2 = Automatic
  • 3 = Manual
  • 4 = Disabled
I have to give credit to this Microsoft article: http://support.microsoft.com/kb/248660
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: