Creating virtual directories in Windows using MKLINK

I won’t go into too much detail as to why I needed to do this, but basically I needed a network share to look kinda like a local folder.

After experimenting with NET USE, SUBST and various other solutions, I came across MKLINK.

The syntax is pretty straight forward:

1
2
3
4
5
6
7
8
9
10
11
12
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.

For example:

MKLINK /D “VirtualFolderName” “\\ServerName\ShareFolderName”

Wherever you run that command, it will create the directory “VirtualFolderName” and contain all the files in the network share. Tidy.