Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 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
up vote 18 down vote accepted

You are looking for the command "mklink". Documentation and examples are here:

Example taken from the link:

// To create a symbolic link named MyDocs from the root directory to the \Users\User1\Documents directory, type:
mklink /d \MyDocs \Users\User1\Documents
share|improve this answer
Please note that you need Administrator privileges to create symbolic links. – Andres Riofrio Jul 26 '12 at 21:46

There may be other ways, but the one I'm familiar with is 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

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
According to the link you provided, fsutil hardlink, fsutil hardlink is only for Vista and above. Is there an older version available for Windows 2000 and XP? – matty Jul 8 '15 at 5:34
Indeed it is available for XP, as described in the Windows XP fsutil hardlink docs. I can't testify to its functionality in Windows 2000, but it does work in Windows XP. – matty Jul 8 '15 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .