Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Operating Systems .: Windows Operating Systems .: Windows Scripts and Batch Files .: create batch file to stop and restart application and services

create batch file to stop and restart application and services

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
**********************************************************************************************

 


How helpful was this article to you?

Related Articles

article How to start, stop, pause, resume, or restart a service in XP
Note You must be logged on as an administrator...

(No rating)  3-6-2008    Views: 211   
article How to Restart the Routing and SMTP services in windows 2003
a. In the...

(No rating)  3-17-2008    Views: 120   
article How to Create quick launch shortcuts to lock, restart, and shutdown computer
Windows Vista automatically assigns...

(No rating)  3-27-2008    Views: 137   

User Comments

Add Comment
No comments have been posted.