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
themklink
command is not executed and theCMD
shell is not exited.
Before pressing Enter:
After:
Process Monitor screenshot:
- Trying to run the command as a background process:
cmd /c mklink &
apparently works - themklink
command is executed, but theCMD
shell is not terminated. Every timeEnter
is pressed,CMD
will become the active shell.
Solution 1:
Search your %PATH% for cmd.cmd or cmd.bat. They may interfere with your cmd
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