Saved Bookmarks
| 1. |
Solve : Test to see if Batch File is running? |
|
Answer» Oh, I was thinking to see if there are to sessions of cmd.exe running. Maybe the batch file could create a file when it starts, and delete it when it completes. the only way that you could really quit would to click the exit button in the corner of the screen. Or doing quit. A batch file will quit when it encounters the EXIT command. I may have misunderstood your requirements, but what I was thinking of was something like this: @ECHO Off :: Check if temporary file exists If Exist %temp%\AlreadyRunning.tmp ( Echo This batch file is already running & Goto :EOF) :: Else create it Echo . > %temp%\AlreadyRunning.tmp :: Carry on with remainder of batch file Echo. Echo Do whatever here, then Echo. :: Delete temporary file Del %temp%\AlreadyRunning.tmp My program. Doesn't really have a beginning and an end. It has a old GUI with options.Quote from: BatchFileCommand on March 03, 2009, 07:57:08 PM My program. Doesn't really have a beginning and an end. It has a old GUI with options. all programs have a beginning and an end. instead of exiting the batch file using EXIT, you can REDIRECT to a label that performs the necessary cleanup.Even if it does have a beginning and an end. What if someone doesn't know about the file and clicks the X button in the corner of the screen. Then they would NEVER be able to use it again. This is why I stopped using this method in my batch files/programs early on. |
|