Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing a batch file when its running

I am running a long running batch file. I now realize that I have to add some more commands at the end of the batch file (no changes to exisiting content, just some extra commands). Is it possible to do this, given that most batch files are read incrementally and executed one by one? Or does the system read the entire contents of the file and then runs the job?

like image 790
Ritesh M Nayak Avatar asked May 25 '09 12:05

Ritesh M Nayak


People also ask

Can you Edit a batch file while it running?

Short answer: yes, batch files can modify themselves whilst running.

How do you abort a batch file?

Ctrl+C. One of the most universal methods of aborting a batch file, command, or another program while it's running is to press and hold Ctrl + C . This keyboard shortcut sends a SIGINT signal, which cancels or terminates the currently-running program and returns you to the command line.

Can I control a program using a batch file once its been started?

Can I control a program using a batch file once its been started? No. A batch file can only execute or start another program. Once it is started, it cannot perform additional functions within that program.


1 Answers

I just tried it, and against my intuition, it picked up the new commands at the end (on Windows XP)

I created a batch file containing

echo Hello pause echo world 

I ran the file, and while it was paused, added

echo Salute 

Saved it and pressed enter to contine the pause, all three prompts were echoed to the console.

So, go for it!

like image 199
Binary Worrier Avatar answered Sep 25 '22 21:09

Binary Worrier