1

I have a build script I'm using in a project I'm currently working on. I found that a certain command only works from cmd and not WSL, but I want to continue to work in WSL.

I have something like this:

command1 && command2 && command3

Say command2 only works in cmd. How can I make this script switch to cmd, execute a command and switch back to WSL?

3
  • @tripleee I tried a few things and cmd.exe /c "command2" indeed works. Thanks! Just curious, what does /c do? Google can't search for puncuation unfortunately. Commented Aug 11, 2021 at 10:44
  • 2
    Searching for "cmd options" gets me learn.microsoft.com/en-us/windows-server/administration/… (which of course is a Microsoft page, so it will probably have moved by the time you try to click). Commented Aug 11, 2021 at 12:39
  • 1
    Use the command cmd /? or "%ComSpec%" /? and read all about it. Commented Aug 11, 2021 at 15:45

1 Answer 1

1

You can simply run cmd /c "command2".

The option /c says to read the script from the next command-line argument, rather than from a file or the interactive prompt.

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

3 Comments

I tried to look for a duplicate but couldn't find one.
Probably because such a duplicate doesn't exist.
You should generally use the /D option with cmd.exe too, and may also want to consider /mnt/c/windows/system32/cmd.exe.

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.