Virtual Geek

Tales from real IT system administrators world and non-production environment


One friend of mine from application developer stream approached me with request, There is a shared network path and he wanted it to be use as a folder on the Windows drive, Instead of mapped drive. So it looks local folder under the drive. For this requirement there is solution called symbolic link or symlink, I had seen and deployed this feature in Linux based systems, Many windows administrator may not be familiar with it, now task was to use it on Microsoft Windows. So there is a command mklink exist for the same purpose. Open command prompt and run mklink. it shows how to use it with parameters.

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.

mklink create a symbolic link Microsoft Windows hard link vs soft symlink

I am using below command to create one link, below are the link and target details used with /D parameter. you can choose your own directory paths for testing. when using it make sure where you are going to create a link that folder drive should be NTFS also command prompt should be running as an Administrator.
mklink /D c:\scripts\sharedpath \\\Temp\testfolder

/D -- Creates a directory symbolic link
c:\scripts\sharepath --(Link)  This is the link, Make sure you don't have folder sharepath named under c:\scripts (you can choose your own folder and name this is just ofr demo purpose)
\\\temp\testfolder --(Target) This is my network shared drive.

once link is created it is giving me the successful message of "symbolic link created for C:\scripts\sharepath <<-->> \\\Temp\TestFolder". When checked under c:\Scripts folder, I see there is shortcut created, but this is not just an ordinary shortcut. To prove it in the command prompt on the 2nd step I changed directory just I use it for any other directory  and ran dir, Voila!, I am seeing it as a proper folder/directory.

mklink create a symbolic link on windows with network share drive

To check further in real action it can be seen in the next screenshot what is the real differance between Symbolic link and shorcut is, I created one shortcut. both icon looks same. but when trying run dir in the command prompt. I see the system cannot find the path specified. Also shortcut can be modified and symlink cannot be.

mklink symbolic hard or soft link vs shortcut folder microsoft windows

Also when running command dir on c:\scripts, I can differantiate between symbolic link and shortcut. There is property SYMLINKED and shortcut is just a file with .lnk extention. Very handy tool indeed.

Differance between, mklink symbolic hard or soft link vs shortcut folder microsoft windows symlink

Go Back


Blog Search

Page Views


Follow me on Blogarama