Does Windows have the ln -s or equivalent?

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 ?


Solution 1:

You are looking for the command "mklink".

Documentation and examples in Microsoft Docs or ss64.com.

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

Solution 2:

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.

Solution 3:

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