1.

Solve : Kill the previous step - Batch File?

Answer»

I have a small batch file that is designed to let the user know that the email client is going to close and then starts the program that gracefully kills the email client.

The problem with this program, Close Goldmine.exe is that if the user doesn't have GoldMine open on their desktop, Close Goldmine.exe doesn't terminate. If it doesn't terminate than the remainder of the batch file doesn't carry out.

Is there a way to either kill the Close Goldmine.exe step in the batch file or program it to run for only a certain number of seconds?

I've tried using taskkill and pskill in the batch file but they don't execute because Close Goldmine.exe is still running.
For this same reason I can't call another batch file to kill this step.

Any ideas?When you say
Quote from: powlaz on May 31, 2007, 12:30:38 PM

The problem with this program, Close Goldmine.exe is that if the user doesn't have GoldMine open on their desktop, Close Goldmine.exe doesn't terminate.
Does that mean that the GoldMine program isn't running at all on their computer, or it just isn't one of the open Windows on their Desktop?

Assuming the former, run a test for it, and if it is not running, then you can skip that section of the batch file. Something LIKE:
Code: [Select]tasklist /fi "imagename eq goldmine.exe" | findstr /i goldmine
if errorlevel 1 goto :Next
echo Your email client is going to close
closegoldmine.exe
:Next
rem the rest of your scriptGary, thanks for keeping pace with me here. I know I've got a lot of threads going.

What I meant by Quote
The problem with this program, Close Goldmine.exe is that if the user doesn't have GoldMine open on their desktop, Close Goldmine.exe doesn't terminate.
is . . .

Before everyone logs out to go home for the night they are supposed to shut down the programs they are using. On of them is GoldMine.
A lot of them don't. This screws up the backup process.
Someone created the Close GoldMine program to quickly and gracefully sever any open connections to the dBase database AND close the program window. So if the user doesn't terminate their session, this little program will.

The idea is for GoldMine to not be running at all on the local machine.

Close GoldMine.exe is an awesome little program with one big fault - if the user DOES PROPERLY close (end, X-out-of, terminate) all of their open programs (like GoldMine) when Close GoldMine.exe goes to run it finds that GoldMine is not there and it . . . hangs out. It does nothing. It stays open.

So on a computer that was properly logged off once the batch file reaches the part where Close GoldMine.exe is called - it hangs. I guess what I NEED is an "IF" statement. Can you help me with that?

If GoldMine (gmw6.exe) is open
then run Close GoldMine.exe
If GoldMine (gmw6.exe) is not open
then don't run Close GoldMine.exe, just go to the next line in the batch file.

Can you translate that into DOS for me?

Thanks,

Matt

Quote from: powlaz on June 04, 2007, 11:07:24 AM
So on a computer that was properly logged off once the batch file reaches the part where Close GoldMine.exe is called - it hangs. I guess what I need is an "IF" statement. Can you help me with that?

If GoldMine (gmw6.exe) is open
then run Close GoldMine.exe
If GoldMine (gmw6.exe) is not open
then don't run Close GoldMine.exe, just go to the next line in the batch file.

Can you translate that into DOS for me?


This one line should do it. Is "Close GoldMine.exe" the name of the program? If it has a space in the name you'll need the quotes I think, and maybe the full path to the executable would be advisable, unless it's in the same folder as the batch file.

tasklist | findstr "gmw6.exe" && run "Close GoldMine.exe"

If gmw6.exe is in the list of running tasks generated by Tasklist, then, the line will execute whatever is to the right of the &&. If it doesn't find it, it'll do nothing. Findstr is case sensitive, so check in Task MANAGER that it it spelled correctly.






Contrex - this looks perfect. I tried it last night and it did exactly what I wanted. Now I don't need to fret about scheduling Close Goldmine.exe.

. . . of course I will need to WORRY about scheduling the batch file. Thanks for getting me over the hump!!

Matt


Discussion

No Comment Found