Using the mklink Command in Windows
The command that you need to use is mklink, which you’ll use from the command line. Just type it on the command line to see the options:
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
/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
For instance, if you wanted to make the folder C:UsersJasTest available from C:Test as well, you could use the following command.
C:mklink /D C:Test C:UsersJasTest
symbolic link created for C:Test <<===>> C:UsersJasTest
Now if you look in C:Test directory, you’ll see whatever files were in the other directory.
Understanding the Options.
MKLINK link target
Using the command without any extra options creates a soft link to a file.
/D creates a symbolic link, or a soft link.
This essentially acts like a shortcut to a folder in prior versions of Windows, except you don’t have to use an actual shortcut.
/H creates a hard link, which points directly to the file.
This option can’t be used for folders directly for some reason, you’ll have to use the next option.
/J creates a “Directory Junction”
A Directory Junction is actually just a hard link to a directory. This is a feature that existed prior to Vista as well. If you are trying to symlink to a directory using a hard link, then you should use this option.
Understanding Hard vs Soft Links
A hard link directly points to the file, and acts to the operating system as if it is the file itself. You’ll want to use this option the majority of the time if you are trying to fake an application’s directory.
A soft link is essentially a shortcut to a file or folder – if you are using Windows explorer, you’ll be redirected to the directory if you double-click on a shortcut, it won’t pretend its part of the filesystem. You can still directly reference or open a file with the symlinked path, and it mostly works.
Using Symlinks from a Network Share
One of the things that’s been extensively discussed is that you cannot use the Vista symlinks from another operating system (not surprising), but you cannot use them from a network share either. This is troublesome if you expect to use this feature on a web server or a file server.
To delete a symlink, you can just delete the link. Just make sure you don’t delete the original file.