Computer Hope

Microsoft => Microsoft DOS => Topic started by: Teroro on October 28, 2021, 02:43:23 PM

Title: Run CMD Commands in Batch Files
Post by: Teroro on October 28, 2021, 02:43:23 PM
How do I run multiple cmd commands in a batch file?

I tried this and it works
Code: [Select]
cmd /k "cd C:\Users\TE IUBESC!!!MAMI\OneDrive\Desktop\Sheesh"But after that the program stops doing anything.
How can I add more commands after that?
Like run this command right after the previous command then close the window?
Title: Re: Run CMD Commands in Batch Files
Post by: Squashman on October 28, 2021, 02:52:05 PM
There is no need to use CMD /K
Code: [Select]
cd /D "C:\Users\TE IUBESC!!!MAMI\OneDrive\Desktop\Sheesh"
echo I am in this folder: %cd%
echo Let's start notepad
start "" "notepad.exe"
Title: Re: Run CMD Commands in Batch Files
Post by: Geek-9pm on October 28, 2021, 09:07:20 PM
This may help.
https://ss64.com/nt/cmd.html (https://ss64.com/nt/cmd.html)
Quote
/K     Run Command and then return to the CMD prompt.
          This is useful for testing, to examine variables
;D