Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File Help

Status
Not open for further replies.
Apr 25, 2001
18
US
I need to create a batch file to run in a Win 98 environment that will periodically check a given program and start it if it is shut down. The program has to run at given times in the day but our users keep turning it off. Any help would be great.

Thanks
 
Don't know of a way off of the top of my head. You might look for a utility to do this, but if you can't find one, you might consider the following....

what happens if you try to run two instances of the program? If the second instance refuses to run, then just put the program into the task scheduler. It will run at those given times, and if it is already running when the task scheduler calls it, then no problem.

If it will allow you to have two instances, you might try to create a batch file that runs the program in the first place. Believe it or not, I actually do this with a program and it works fine (although I do not use the task scheduler--I just do it to make sure that only one instance of a certain program can run at any given time)

Simply put, the batch file would
A) check for the existance of a key file on the hard drive
B) if the key file is not there, create it and start the program (using call c:\directory\program.exe)
C) if the key file is there, then exit the batch file (assumes that the program is running because the key file is present)
D) deletes the keyfile when the program closes
Then just put that batch file into the program scheduler.

Depending on your program, this may or may not work--might take some playing with to get it right. Also, the down side is that if the user closes the program by using ctrl alt del, then it may leave the key file on the hard drive. Could be a pain.

Here is a simple example of what you might do (I use win2k on this PC, hence the winnt dirs).

if exist statement looking for c:\temp.txt, if found goto exit
c:
cd \winnt\system32
echo hello>>c:\temp\test.txt
call sol.exe
del c:\temp\test.txt
:exit Mudskipper
___________________________________________________________________________________

Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top