• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

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

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
gboo19
Asked:
gboo19
  • 2
1 Solution
 
ZoppoCommented:
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
 
gboo19Author Commented:
Perfect!  Exactly the fix i needed.  Thanks!
0
 
ZoppoCommented:
You're welcome - I'm glad I could help.

Have a nice day,

best regards,

ZOPPO
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now