1

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:

  1. Switch volume
  2. Direct to a directory in that volume.

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?

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

What don't you just open your cmd at the needed directory? Like^

start /dc:\temp cmd

Comments

0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.