Nafalem
Nafalem

Reputation: 371

CMD.exe write bat file with multiple commands

I try to create bat file with cmd.exe and add pause command, but cmd.exe then write to bat file "Press any key to continue . . ."

C:\Windows\System32\cmd.exe /k cd\ & C: & echo "C:\windows\notepad.exe" & pause > test.bat

final bat file should contain:

"C:\windows\notepad.exe" & pause

Upvotes: 0

Views: 874

Answers (1)

r3ap3r
r3ap3r

Reputation: 2815

You can use this to create the batch file :

echo "C:\windows\notepad.exe\" ^& pause>> C:\test.bat

Why do you have to use cmd.exe to create a batch file?

If you have to use the command which you had asked in the question then format it like this:

echo exit | C:\Windows\System32\cmd.exe /k cd\ & echo "C:\windows\notepad.exe\" ^& pause>> C:\test.bat

Upvotes: 1

Related Questions