Could try this:
Main Topics
Browse All TopicsHi all,
I am not very good wioth DOS commands so here it is...
I need 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
Anyone have the necessary code to do this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Try something like the following:
taskkill /IM MyApp.exe
net stop "SQL Server"
net stop "SQL Agent"
ping 127.0.0.1 -n 301 -w 1000
net start "SQL Agent"
net start "SQL Server"
MyApp.exe
The net stop/start commands may be slightly incorrect - if you do a "net start" from a command line, i.e. with no parameters, it'll list all the services available, including the correct names of the SQL services.
oBdA and SteveGTR - THANK YOU SO MUCH!!!!
I split the points because:
oBdA - Your answer is right on except for 2 parts which were supplied by SteveGTR.
1.) The net stop and start commands
2.) Sleep doesn't work in windows 2003.
So, when I combined the 2 response from you guys it worked PERFECT!!
Thanks again!
DL
Business Accounts
Answer for Membership
by: oBdAPosted on 2007-12-05 at 12:03:29ID: 20414449
I don't have the exact service names at hand at the moment, but you can retrieve them in a command window using
ownloads/d etails.asp x? familyid =9d467a69- 57ff-4ae7- 96ee-b18c4 790cffd&di splaylang= en
net start
which shows all running services.
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"
Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/d