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 need to link a file to c:\Windows\System32\drivers\etc\hosts. How can I do that with windows? Is there a soft link such as 'ln -s' or equivalent in Windows?

share|improve this question

4 Answers 4

up vote 11 down vote accepted

You are looking for the command "mklink". Documentation and examples are here: http://technet.microsoft.com/en-us/library/cc753194%28WS.10%29.aspx

share|improve this answer
    
Please note that you need Administrator privileges to create symbolic links. –  Andres Riofrio Jul 26 '12 at 21:46

As @inf says, mklink is the solution for Vista and above.

For 2000/XP, you can use fsutil hardlink. Note that, unlike mklink, hardlink doesn't work across drives.

share|improve this answer
    
Also worthy of note is that some people may not be aware, but hardlinks become the file. In other words it's possible to delete the original and the link still works (and this is why it can't work across drives). –  Camilo Martin Sep 9 '13 at 2:05

There may be other ways, but the one I'm familiar with is mklink:

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.
share|improve this answer

There are junctions but I don't know if this will do exactly what you need.

edit - oops sorry, junction only applies to directories not files

share|improve this answer

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.