Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand that Windows later-than-or-equal-to* Vista provides the mklink shell command. I'd like to make use of this from the Msys terminal. Any idea how?

When I enter mklink on the msys terminal, it outputs sh: mklink: command not found. Msys only provides a fake ln utility which appears to be effectively the same as cp.

I tried writing a shell script to open a Windows shell and run mklink within it, but when my shell script tries to execute cmd /C <instructions>, msys brings the Windows shell to the foreground of the current terminal and leaves it there, without running the instructions.

*I don't say 'greater-than-or-equal-to' because XP was greater than Vista but had no mklink utility.

share|improve this question

Using cmd /c mklink directly on the MSYS bash command line should work.

$ cmd /c mklink
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

Note that the mklink command and arguments need to be provided as a single argument to cmd, like so:

cmd  /c 'mklink link target'
share|improve this answer
    
I get the same result as you when I enter the command you entered, but when I supply the necessary arguments to actually make a link cmd /c mklink <link> <target>, then it opens the Windows shell in my current msys window. – JellicleCat Feb 14 '13 at 18:11
    
Ah, the mklink command and arguments need to be quoted. Answer amended accordingly. – ak2 Feb 15 '13 at 9:19
2  
...AND you need to escape the /c parameter, using //c instead. See superuser.com/a/526777/50251. – rsenna May 24 '14 at 3:36
    
Not much consolation, but I am trying to get mklink working without msys in a makefile and it is causing no end of pain. The cmd /c thing almost worked, but then incapacitated mingw32-make (no further output). Wonderful. Think I'm going to find a way to avoid symlinks if this is the case! – Arcane Engineer Jul 5 '15 at 15:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.