Reputation: 89
I'm making a batch file that starts a program, for example notepad.exe
. I need it to execute a command after I have closed notepad.exe
manually.
I only know that in order to do this, the batch file will have to verify if the process notepad.exe
is running or not.
How can I make it verify this exactly when I have closed the Notepad window manually?
Upvotes: 3
Views: 10711
Reputation: 6620
The answer is not to do anything.
I'm guessing your currently using the start
command. The thing is the start
command starts the program and then continues on. If you call the program as an "operable program or batch file"
then it will wait for the program to end before continuing.
You learn this stuff when automating batch commands and creating macros.
Say you wanted to run notepad.exe with a file named file.txt and then type it,
notepad.exe file.txt
type file.txt
No start
. If that's not it show us your code and then we may be able to tell you why.
Upvotes: 2
Reputation: 883
If you are using start
, you can /wait
for the program to finish before running any more commands:
(commands)
start "" /wait notepad.exe
(commands to run here)
Replace notepad.exe
with the path to the program. You can also add parameters after notepad.exe
to pass to the program.
The program will wait for notepad.exe
to close first before running the commands below.
Upvotes: 4