How to run internal cmd command from the msys shell?

The Windows CMD utility has a number of internal commands, such as mklink. How can they be used from the msys shell ?

From CMD's documentation, the /c switch can be used to execute a command and exit; but this doesn't seem to work.

  • If I do cmd /c mklink the mklink command is not executed and the CMD shell is not exited.

Before pressing Enter:

enter image description here

After:

enter image description here

Process Monitor screenshot:

enter image description here

  • Trying to run the command as a background process: cmd /c mklink & apparently works - the mklink command is executed, but the CMD shell is not terminated. Every time Enter is pressed, CMD will become the active shell.

Solution 1:

  1. Search your %PATH% for cmd.cmd or cmd.bat. They may interfere with your cmd

  2. Run Process Monitor and run your cmd /c mklink. Examine ProcMon log for really executed commands.

Solution 2:

win7/cygwin/bash had same problem, solution is to launch cmd twice, and convert slashes to backslashes as needed by cmd (for example): REPO_DIR=${REPO_DIR////\\} # Example, Turn c:/cvs into c:\cvs for cmd
cmd /C "cmd /C mklink /D .Repo $REPO_DIR" # launch cmd /C cmd /C cmd