I have a batch file, mybatch.cmd
, which successfully opens 3 command line windows:
start "CMD LINE 1" CD C:\dir1
start "CMD LINE 2" CD C:\dir2
start "CMD LINE 3" CD C:\dir3
But I want to expand this to issue a subsequent command (e.g., "echo test") within each new window. So I tried this:
start "CMD LINE 1" CD C:\dir1 echo test
start "CMD LINE 2" CD C:\dir2 echo test
start "CMD LINE 3" CD C:\dir3 echo test
But that gives me The system cannot find the path specified
. Any suggestions?
I realize this question seems like a duplicate of this. But none of those answers are working for me.
Specifically, neither /c or /k seem to do the trick - though they do work when I remove the CD
part of my command. It's almost like the CD
is incompatible with the /c
and /k
.
Solution:
Fixed by modifying each line to 1) add cmd.exe; 2) put commands in quotes, separated by &
:
start "CMD LINE 1" cmd.exe /D /K "CD C:\SOURCE & echo test"
Note it's probably best to specify the full path to cmd.exe, as shown in the answer below, but I left that off for simplicity (and it works).