Sign in with
Sign up | Sign in
Your question

Stop service using batch file

Last response: in Windows 8
May 25, 2013 4:43:29 AM

I've searched Google, I've read other threads on this, but got no clear answer.

I'm in need of a batch file that will set a service's startup type to disabled AND immediately stop the service if it is currently running as well. I've never dealt with batch files before. How do I go about doing this?

I would also need some way of making the batch file run on every startup. I assume an easy way to do this would be to put a shortcut to the batch file to the startup menu in the start menu (I'm using classic start menu)
a b * Windows 8
May 25, 2013 5:32:03 AM

EDIT - Just noticed this is for Windows 8. Not sure if this is at all relevant as I'm not familiar with Windows 8

Batch files are simply lines of commands saved into a file with a ".bat" extension. Example - mystartup.bat.
You can create and save these files using any text editor like notepad.
Saving the file in your startup folder will have the batch file execute each time you boot your system.
The command line for starting and/or stopping a service is as follows:

  1. net start <servicename>
  2. net stop <servicename>

The command for setting a service start to disabled is as follows:

  1. sc config <servicename> start= disabled

So if you wanted to shut down and disable a service called "indexing", you would create a batch file with the following two lines of code"

  1. net stop indexing
  2. sc config indexing start= disabled

Note the spacing as apparently, it's required.

-Wolf sends
May 25, 2013 5:42:31 AM

Thanks - though neither commands appear to be working. I see other batch files sometimes have @echo off at the start. Do I need any special commands like this as well?
Related resources
a b * Windows 8
May 25, 2013 5:46:51 AM

Again, I'm not familiar with Windows 8 so I can't say for sure. "@echo off" is just a command to hide the command line execution output and isn't really needed.

-Wolf sends

Edit: Based on what I found here, the commands should be the same (or very similar).

May 25, 2013 6:49:48 AM

Seems like several commands aren't working. I can't even net send myself a note.