Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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
    
...AND you need to escape the /c parameter, using //c instead. See superuser.com/a/526777/50251. –  rsenna May 24 at 3:36

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.