Reputation: 495
I tried to run multi-windows commands inside one opened window from a batch file.
I want the opened command window to perform two things in sequence:
Here's what I wrote:
start cmd /k C: && cd 'C:\Program Files (x86)\aaa\'
However, this only switches volume. The second thing is not executed.
Can anyone please show me the way?
Upvotes: 1
Views: 2403
Reputation: 31251
If you want to change directory to another drive you can use
cd /d C:\
but if your changing directory within the same drive you shouldn't need to switch drives, just change to that directory:
cd "C:\Program Files (x86)\aaa"
Remember to put quotes around paths with spaces, possibly why your command didn't work earlier.
Also, you shouldn't really need start
and cmd
. What you doing doesn't really need to be threaded as such. If it's a batch file you can just use pause
at the end instead of using cmd /k
.
Your complete batch file would then look like this:
cd "C:\Program Files (x86)\aaa"
pause >nul
or using cmd /k
for one line (in case of command line use):
cmd /k cd "C:\Program Files (x86)\aaa"
Hope this helps!
Upvotes: 0
Reputation: 4219
What don't you just open your cmd at the needed directory? Like^
start /dc:\temp cmd
Upvotes: 0
Reputation: 8660
Well, you have at least 2 options...: 1st, make sure your && is passed to new cmd...
start cmd /k "C: && CD c:\temp"
2nd, use /d switch on cd to "get there" in one step...
start cmd /k cd /d c:\temp
KR Bartek
Upvotes: 1