To create a bacth file that will perform the following actions in order
1.) Terminate an application such as MyApp.exe
2.) Stop MSSQL server
3.) Stop MSSQL Agent
4.) Wait 5 minutes
5.) Start MSSQL Server
6.) Start MSSQL Agent
7.0 Start MyApp.exe
**********************************************************************************************
* The SQL Agent should be stopped before the SQL server, it's dependent on the server
Basically it would look like this (the service names still need to be corrected); sleep.exe is part of the W2k3 ResKit (see link below):
taskkill /im "MyApp.exe"
net stop "MSSQL Agent"
net stop "MSSQL Server"
sleep 300
net stop "MSSQL Server"
net stop "MSSQL Agent"
start "" "MyApp.exe
**********************************************************************************************
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
|
@echo off
net stop MSSQLServer
net stop SQLServerAgent
echo Waiting for 5 minutes
ping -n 301 127.0.0.1 > NUL
net start MSSQLServer
net start SQLServerAgent
start myapp.exe
|
**********************************************************************************************