The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation

Essential Tools for Windows Services: The NET Command

If you manage Windows Services and are comfortable working from the command line, then the Windows NET.EXE command should be in your toolkit. Use it to easily start, stop, pause or restart any service from an elevated command prompt, or in a convenient script/batch file.

Using NET to stop a Windows Service

To stop a service, run:

net stop <Service-Name>

where <Service-Name> is the name of the service. Be sure to enclose it in quotes if it contains a space!

For example, to stop the Print Spooler service (named “Spooler”), run:

net stop Spooler

Here is what it looks like on our Windows Server 2016 computer:

NET: Stopping the Print Spooler Service

Notice that the NET command will wait for the service to stop before continuing. The only exception is when the service is unresponsive or takes more than 30 seconds to comply.

Starting a Windows Service with NET

To start an idle Windows Service, run:

net start <Service-Name>

If all goes well, your service (and any other service it depends on to operate) will be started after a few seconds:

NET: Start the Print Spooler Service

How to Restart a Windows Service with NET.EXE

To restart a service, say from a batch file, chain the “net stop” and “net start” commands together like this:

net stop <Service-Name>
net start <Service-Name>

NET will also Pause and Resume Windows Services

Not all services support pause and resume, but if you have one that does, NET can come in handy there as well.

To pause a service, type:

net pause <Service-Name>

To resume a paused service, run:

net continue <Service-Name>

Posted in Windows Services | Tagged , , | 28 Comments

28 Responses to Essential Tools for Windows Services: The NET Command

  1. Art Wilmoth says:

    On using the NET command in a batch to restart I recommend adding time for the services to react. I’ve done this for one of my services that tends to hang. See below;

    @ECHO Stopping services, please wait for 10 seconds…

    REM Stop Service

    NET STOP ServiceNameHere

    REM The following is a timer to allow for server RAM to clear after the service has stopped
    REM Use the numerical value within the ‘timeout’ command line to control how many seconds the pause will be.


    NET START ServiceNameHere



  2. Sunny says:

    I have a query if I need to start the multiple services and those service is taking more than 30 seconds to come up then how can i achieve that as currently its failing with error “‘net’ timed out after 30 seconds”.

    Appreciate your early response. thanks

    • Core Technologies Consulting says:

      Hi. We recommend creating a batch file that uses the SC command to stop the service and check on it later.

      To stop the service with SC, use:
      SC STOP servicename

      To check if a service was successfully stopped (after you wait for longer than 30 seconds), use the following command:
      SC QUERY servicename | FIND “STATE” | FIND “STOPPED”

      It will set the %ERRORLEVEL% variable to 1 if the service is not in the Stopped state.

      Click here for some info on SC.

  3. Sean Sparks says:

    I need a script to test users ability to start a service. Multiple users on multiple servers. Can i do that with SC or NET commands?

  4. Core Technologies Consulting says:

    Though its results may be tricky to decipher, you can use the “SC SDSHOW” command to see the service’s security descriptor.

    If you don’t mind attempting to start the service, you can also use NET START and search for errors, as shown in the example on this page.

  5. Ajay says:

    sir net stop telnet how to use this cmd

  6. Brandon Hutson says:

    Make note that if the service name is two words or more you must enclose the name with quotation marks. Took me a while to find that!

  7. Suraj Shrivastav says:

    I want to restart services on multiple windows servers and it take around 1 minute to be stopped . I tried to use NET STOP but its not waiting and just executed next command to start . Can someone please help me with the exact script which i can use to restart services on multiple servers.

  8. Core Technologies Consulting says:

    NET STOP will only wait for about 30 seconds for the service to stop. If a service takes longer than a few seconds, NET will fail with an “Unable to wait” message.

    Unfortunately there is no way to tell NET STOP to “wait longer”. And the SC utility won’t be any help as it doesn’t even attempt to wait.

    We recommend using the “safeServiceStop.bat” (or “safeServiceRestart.bat”) batch file described in this article.

    Save the batch file to your file system and call it from your existing batch file. Note that you should add “localhost” when calling the new batch file. For example, to stop a service called “Spooler”, use

    safeServiceStop localhost Spooler

    Note that the recommended solution will wait indefinitely for the service to stop. If the service never stops, your script will hang.



    UPDATE 8/27/2018: We have created a free command line utility (called ServicePilot) that will wait for as long as you like when stopping the service. You can use it instead of the batch file recommended above — it’s a much simpler alternative.

    Be sure to specify an appropriate value for the “-wait” flag when using ServicePilot. For example, to stop the Spooler service when it may take 5 minutes (300 seconds) to comply, use:

    ServicePilot -wait 300 Spooler

    Note that the service will be forcibly terminated if it doesn’t stop gracefully in the given time frame.

  9. Jorge says:

    Stopd service Tobii. It does not accept the Net Start command, and Sc start, says that the command is invalid, service name (Tobii Service)

  10. Core Technologies Consulting says:

    What command are you using to stop Tobii?

    Make sure you are specifying the name of the service. And enclose the name in quotes if it contains a space!

    • Jorge says:

      It was right, I was putting the name without (“) hence it was wrong, now it worked out ,,, Net start” Tobii Service “

  11. Martin Hydén says:

    If I use net stop and and net start on a special service that have stoped working correct it doesn’t help, it still working incorrect.
    But when restart the same service from services.msc it reset the service correct. What is the difference?

    (service name is in one word, so not the quotes problem..)

  12. Core Technologies Consulting says:

    Does NET STOP/START print any error messages to the console? Perhaps it is failing and not actually stopping/starting the service.

    A common problem: NET STOP/START will fail if you are not running with sufficient rights. Make sure that you are working in an elevated prompt (started with “Run as Administrator”).

    • Martin Hydén says:

      Thank you. No error messages, it just says that the servicie is stopped. And yes I run it elevated.
      I will try timeout from the first comment next time i’m at the actual computer.

  13. Joseph Sharp says:

    A really common problem when the net or SC commands and some custom services is that you have to specifiy the “Service Name” not the “Display Name” Many times they are the same but not always. Right click on the service in services.msc to see the two on the general tab and make sure you are doing “Net Start servicename” – and as said above, you still have to put it in quotes if it’s got spaces.

    You can change the name with sc to make it easier if you want but obviously, this might be a bad idea with system/windows services.

    • Joseph Sharp says:

      BTW, I know the article actually does say this but the link for “name of service” which explains this is kind of subtle and I think people might be missing that.

  14. Core Technologies Consulting says:

    Thank you for pointing out the important difference between “Service Name” and “Display Name”.

    Yes, we do mention the need to use the “Service Name” in the article, but maybe there is a way to make it more prominent. We’ll think about it — let us know if you have any ideas that don’t detract from the main focus of the article (using NET).

    Note that our free ServicePilot utility (a more fully-featured alternative to NET.EXE) removes the name confusion by accepting both the “Service Name” and the “Display Name”. You can use either one!

  15. Steve Barnhard says:

    Spotlight on Art. Amazy due. This got me the possibly best task ever. exactly 30 seconds after I log on, simultaneous to the desktop resolving over my SSD run system I am watching a slightly modded version of your script rock the Synergy service off then on in about 20 seconds flat. I have been, hitherto on every login for ~6 months since getting Synergy having to click a taskbar icon for Synergy, then stop and start in the program, because it won’t start client clicks until the service restarts. Simply the best. Here is my modded script:
    @ECHO Stopping services, please wait for 10 seconds…

    REM Stop Service

    NET STOP Synergy


    NET START Synergy

    TIMEOUT /t -1

  16. Steve Barnhard says:

    forgot to thank YOU core technologies, for your recent help in getting my TASK SCHEDULER started..albeit on a completely different computer than the one mentioned above.

  17. Rod Nibbe says:

    If the service isn’t running the START won’t happen unless you format it like this:

    net stop
    net start

    If the service isn’t running, the first line will throw and error, but the second line will pick up and start the service for you.

  18. Shanmuga bharathi says:

    I want to restart some specific service for a specific time every week.

    if I used the above commands given will it work?

    and if it fails to stop the service by-case will I get any email notification or is there any way to get the notification through email to me if something goes wrong?

    also if the restart thorough the batch file get succeeded, will I get notified through anyway instead logging in & checking windows logs

  19. Core Technologies Consulting says:

    Hi Shanmuga.

    Yes — you can use the above NET commands in conjunction with the Windows Task Scheduler to restart a specific service at a specific time. We’ll add a blog article digging into the details and let you know when it’s up.

    Unfortunately there is no simple, built-in way for Windows to notify you if a service operation succeeds or fails. Some administrators of large sites have set up tools that monitor the Event Log for important events and deliver alerts, but that may be overkill if you are not in an enterprise environment.

  20. Hi Shanmuga.

    Check out our new blog article showing how to restart a Windows Service at a specific time each week.

    Let us know if that solution doesn’t work for you.

  21. User_India_Noida says:

    Hi all,

    I have got two batch files written within my application to stop and start a windows service.
    Is there a way for me to check the status of the said service (whether it is stopped or not) and restart the same at a specific time during the day?
    For more clarity –
    The application service stops at, say 11pm at night and starts at 11:15pm again.
    Is there a way to write time bound conditions for restarting a script excluding the duration 23:00-23:15?

    Apologies if it doesnt make much sense.

  22. Hi. You can use this simple batch file to check if a service is running or not:

    sc query "%1" | find "RUNNING" > NULL
    	echo Service "%1" is NOT running.
    ) ELSE (
    	echo Service "%1" is running.

    Save those lines to a new .BAT file and pass the name of your service (not the display name) as the first parameter.

    With regards to stopping at a specific time and restarting at another time, we recommend using the Windows Task Scheduler.

    Create a basic task that stops your service at 11 PM (a batch file running NET STOP) and another that starts the service at 11:15 PM (with NET START).
    The process is outlined in the “Restart multiple times per day (using the Windows Task Scheduler)” section of this related article.

Leave a Reply

Your email address will not be published. Required fields are marked *