Solved

Help with Batch File to run a program for a specific length of time

Posted on 2011-09-15
3
323 Views
Last Modified: 2013-12-04
I am trying to create a batch to run a program for a specific length of time, then kill the program and restart it.  My batch file so far is:

:start
taskkill /f /im pandora.exe                                   (if pgm running, kill it)
ping -n 10 -w 1000 127.0.0.1 > nul                     (wait a specified time before restarting)
c:\progra~1\pandora\pandora.exe                     (starts or restarts the program)
ping -n 10 -w 1000 127.0.0.1 > nul                     (wait a specified time then loop the batch file)
goto start

The batch file works fine until it starts the program.  The program runs fine, but never goes to the next line in the batch file to start the timer to begin the loop to stop the program again.

Any ideas?
0
Comment
Question by:gboo19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 36542926
Hi gboo19,

you can use 'start' command, i.e.:
start c:\progra~1\pandora\pandora.exe

Open in new window

If it's a console program and you want to supress the new created DOS window you can add a '/B' like i.e.:
start /B c:\progra~1\pandora\pandora.exe

Open in new window

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:gboo19
ID: 36542954
Perfect!  Exactly the fix i needed.  Thanks!
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 36543049
You're welcome - I'm glad I could help.

Have a nice day,

best regards,

ZOPPO
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question