Basically I have written a "script" in notepad and saved it as a .bat
file. All it does is to change directory. Written like this:
cd C:\Users\Hello\Documents\Stuff
It does change the directory, but i want to write more after that, within the cmd
. Ex. choose a program to run. It seems simple, but i can't figure it out. I read about pause
, but it just waits for a key and then closes down.
If you want the command prompt cmd widnow to stay open after executing the last command in batch file –you should write cmd /k command at the end of your batch file.
Type the "cmd /k" parameter before every command to keep the window from closing.
You can insert the pause command before a section of the batch file that you might not want to process. When pause suspends processing of the batch program, you can press CTRL+C and then press Y to stop the batch program.
To prevent the Command Prompt from closing automatically:Press Windows key + R to open the Run window. Adding / K after the command keeps the window open. You can, then, close the window manually when you no longer need it to be open.
Put cmd /k
on the very last line of the script.
Try the following:
@echo off
Cmd /k
cmd /k
starts a new cmd
instance, /k
stops terminating the console window after the commands are finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With