JSI Tip 9361. How can I schedule a job to stop and start the Server service, freeing resources on server?

Jerold Schulman

May 17, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


If your server occasionally requires a restart to make it perform better, you may be able to schedule the stop and start of the server service to free resources.

When you stop the server service, those services dependent upon the server service will also stop, and need to be restarted after your restart the server service.

I have scripted SSSrvSvc.bat to:

  • Disconnect any user sessions

  • Stop the Server service and its' dependent services.

  • Start the Server service.

  • Start the dependent services

You should schedule SSSrvSvc.bat to run in an Administrator or System context, probably once a day, at a time when the fewest clients are active.

SSSrvSvc.bat contains:

@echo offsetlocal ENABLEDELAYEDEXPANSIONgoto skipnet sess /delete /ynet sess /delete /ynet stop Server /y>"%TEMP%Server.log" 2>&1net stop Server /y>>"%TEMP%Server.log" 2>>&1net start Server:skipfor /f "Tokens=1* Delims=:" %%a in ('type "%TEMP%Server.log" ^|Findstr /l /n /v /c:"*$"^|FIND "   "') do ( set line=%%b net start "!line:~3!")del /q "%TEMP%Server.log"endlocal



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like