For example, to stop the Spooler service when it may take 5 minutes (300 seconds) to comply, use:
You can use it instead of the batch file recommended above - it’s a much simpler alternative.īe sure to specify an appropriate value for the “-wait” flag when using ServicePilot.
#WINDOWS LOGGER COMMAND UPDATE#
UPDATE : We have created a free command line utility (called ServicePilot) that will wait for as long as you like when stopping the service. If the service never stops, your script will hang. Note that the recommended solution will wait indefinitely for the service to stop. For example, to stop a service called “Spooler”, use Note that you should add “localhost” when calling the new batch file. Save the batch file to your file system and call it from your existing batch file. We recommend using the “safeServiceStop.bat” (or “safeServiceRestart.bat”) batch file described in this article. And the SC utility won’t be any help as it doesn’t even attempt to wait. Unfortunately there is no way to tell NET STOP to “wait longer”. When it finishes running, the cmdlet will create the classic WindowsUpdate.log file in your Desktop folder. Type the following command at the PowerShell console: Get-WindowsUpdateLog. If a service takes longer than a few seconds, NET will fail with an “Unable to wait” message. To find the Windows Update Log in Windows 10, do the following.
NET STOP will only wait for about 30 seconds for the service to stop. Not all services support pause and resume, but if you have one that does, NET can come in handy there as well. Net start NET will also Pause and Resume Windows Services To restart a service, say from a batch file, chain the “net stop” and “net start” commands together like this:
#WINDOWS LOGGER COMMAND HOW TO#
How to Restart a Windows Service with NET.EXE If all goes well, your service (and any other service it depends on to operate) will be started after a few seconds: The only exception is when the service is unresponsive or takes more than 30 seconds to comply. Notice that the NET command will wait for the service to stop before continuing. Here is what it looks like on our Windows Server 2016 computer: Be sure to enclose it in quotes if it contains a space!įor example, to stop the Print Spooler service (named “Spooler”), run: Use it to easily start, stop, pause or restart any service from an elevated command prompt, or in a convenient script/batch file. If you manage Windows Services and are comfortable working from the command line, then the Windows NET.EXE command should be in your toolkit.