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?

link|improve this question

74% accept rate
feedback

4 Answers

up vote 5 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

link|improve this answer
feedback

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

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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