The Core Technologies Blog

Our Software // 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 DOS 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 , , | 4 Comments

4 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.
    @ECHO Stopping services, please wait for 10 seconds…

    @ECHO OFF
    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.

    TIMEOUT /t 10 /NOBREAK
    ECHO.

    NET START ServiceNameHere

    PAUSE

    EXIT

  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

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>