If you are writing batch scripts, you need to know the command prompt in and out, here’s how to disable or enable services using the command line.
SC Query – Simple Guide On Using Service Control
1. Step Open an elevated command prompt – Don’t knwo how? Here’s how we can open a prompt with admin rights
2. Step Next, we are going to query the SC service name. SC aka Service Control has different names for the services and you cannot disable them using the actual service name listed on services.msc. Instead we need to send a query to get the service name and then we can run a query to disable it
3. Step Start services.msc (enter into search bar or Run)
4. Step Get the name of the service you want to disable e.g.
- Apple Mobile Device
- AMD FUEL Service
- ASP.NET State Service
5. Step Go to the command prompt we opened in step 1 and enter this, replacing the service name with your own.
sc GetKeyName “AMD FUEL Service” (including the quotes!)
As you can see, sc does not account for typos. If you do not enter the service name EXACTLY as seen on the services.msc list, then it will give you the error “The specified service does not exist as an installed service”, no matter what
6. Step Ok, now that we got the SC Key name, we can disable it using a new query:
sc config “AMD Fuel Service” start= disabled
As you can see, I entered the exact key name that SC gave me but added quotes around it, because the service name has spaces in it and Windows command prompt would not recognize it then. Quotes are very important for entering system paths into a command prompt as well, it’s one of the first things you should acknowledge when you write batch scripts
Different Service States And CMD Parameters
In the query above you can replace disabled with the following states:
boot | system | auto | demand | disabled | delayed-auto
For more command line options simply enter sc config /? - this is where you can see various additional command parameters like error, binPath, tag, depend, obj, DisplayName, password