Create Symbolic Links, Hard Links and Directory Junctions in Vista with MKLINK
For Unix-like or Linux system users, symbolic link is a common feature in use almost daily. Symbolic link (aka soft link) or symlink as it often shortened to, is a special type of file or file-system object that serves as a reference or points to another file, UNC or directory, known as target. In Windows Vista, symlinks feature has been added to NTFS filesystem and can be created by using MKLINK command. In previous Windows operating system, the closer thing to symbolic links is NTFS junction point, or worse, Windows shell shortcut (.lnk) file.
Symlink in Vista, unlike .lnk shortcut in desktop or Windows Explorer, allow user to access files within the symbolic link created itself via explorer, the console and etc. And symbolic link also differ from NTFS junction point which can only link to folders and volumes, in which symlinks can point to a file, a UNC, a folder or a volume, as well as able to span file systems.
Symbolic link is useful when you have a lot of folders and files are scattered all over the directory tree, and you need to manage them from a single location. Another scenario is that you have a deep nested file that you want to access quickly instead of traverse through one branch by one branch. And furthermore, for programmer, symlink provides a static file path that can be point to a ever changing object without affecting the functionality of the program. In all these situation, symbolic links can be created at a convenient location which point to the ‘real’ objects.
As mentioned, to create a symbolic link, use MKLINK command line tool. MKLINK can be used to create a hard link or directory junction too. Hard link is essentially giving another name or label to the objects, while NTFS directory junction point is used to redirect the whole folder to another folder as if it’s the original folder itself. Junction point is used extensively in Vista to provide support for old directory structures for user profiles (i.e Documents and Settings) to point to the new user folders located inside Users directory.
Syntax and Options of MKLINK
MKLINK [[/D] | [/H] | [/J]] Link Target
/D - Creates a directory symbolic link. Default to 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.
Examples and Usages of MKLINK
Note: Only Administrators can use MKLINK to create symbolic links unless override by using secpol.msc, so you need to run Command Prompt with elevated privileges, or else you will get “You do not have sufficient privilege to perform this operation.” error.
To create symbolic link called foo to reference to c:\Windows\System32\notepad.exe:
C:\test>mklink foo c:\Windows\System32\notepad.exe
You will see the following result:
symbolic link created for foo <<===>> c:\Windows\System32\notepad.exe
If you type dir in commnd prompt, you will see the following listing:
Volume in drive C has no label.
Volume Serial Number is 2211-7428Directory of C:\test
04/14/2006 11:24 AM <DIR> .
04/14/2006 11:24 AM <DIR> ..
04/14/2006 11:24 AM <SYMLINK> foo [c:\Windows\system32\notepad.exe]
1 File(s) 0 bytes
2 Dir(s) 69,238,722,560 bytes free
To create symbolic link to a folder, simply use /D switch:
C:\test>mklink /d bar c:\windows
symbolic link created for bar <<===>> c:\windows
Results of dir command:
Volume in drive C has no label.
Volume Serial Number is 2211-7428Directory of C:\test
04/14/2006 11:24 AM <DIR> .
04/14/2006 11:24 AM <DIR> ..
04/14/2006 11:24 AM <SYMLINKD> bar [c:\windows]
04/14/2006 11:24 AM <SYMLINK> foo [c:\Windows\system32\notepad.exe]
1 File(s) 0 bytes
3 Dir(s) 69,238,722,560 bytes free
MKLINK cannot use to delete symbolic link. To remove a symbolic link, simply delete them as if you’re removing a normal file. For example, to delete the foo symbolic link created above, enter the following command:
C:\test>del foo
To remove the bar symbolic link to a folder created above, use the following command:
C:\test>rd bar
Share and contribute or get technical support and help at My Digital Life Forums.
Related Articles
- Change Group Ownership of Symbolic Links in Unix or Linux
- How to Make or Create Symbolic Link in Unix or Linux
- Vista IE7 Cache & Cookies Folder, Temp Directory and History Location
- 64-bit (x64) Windows Vista Official Direct Download Links
- Official Vista SP1 RC Standalone Installer Direct Download Links from Microsoft Server
- Automated Installation Kit (AIK) for Windows Server 2008 and Vista SP1 Direct Download Links
- Hide and Remove Public Folders Shortcuts and Favorite Links in Vista Explorer Shell
- Windows Vista SP1 Standalone Setup Package (x86 and x64) Official Download Links Release (Wave0 5 Languages)
- Install and Create Vista Sidebar in Windows XP
- How to Create a Bootable USB Flash Drive or USB Key with Vista WinPE 2.0


























June 2nd, 2007 04:22
[...] Create Symbolic Links, Hard Links and Directory Junctions in Vista with MKLINK » My Digital Life: [...]
June 23rd, 2008 09:36
I cannot figure out how to go to or switch to a symbolic link after it is created. How do you do it? I can’t find instructions for this mentioned anywhere.
June 25th, 2008 06:32
Thanks for the post, but I don’t see the point of creating a symlink to a file. In your example, you created a symlink called “foo” pointing to notepad.exe, but what can you do to the file “foo”? It’s not executable, even after I rename it to foo.exe.
Thanks.
July 22nd, 2008 17:39
you can’t execute symlinks, for that you need to make a shortcut the normal way. A symlink is more usefull for ppl to read a certain file wich is in a folder they normaly can’t go to. Or the same file is needed on 2 different folder locations, but you dont want to edit 2 seperate files all the time.
October 16th, 2008 20:19
JUNCTION.EXE is a command line tools that allows local symlinks in NTFS volumes under windows XP.
October 23rd, 2008 15:17
Buongiorno,
mi complimento per il tuo lavoro, ma ho da sottoporti un quesito difficilissimo, che se riuscirai a risolvere ti farò una DONAZIONE.
Ho la necessità di fare un LINK SIMBOLICO alla cartella DESKTOP, ma purtroppo dopo averlo fatto non mi sarà più possibile cancellare file o cartelle dal DESKTOP a causa di una limitazione di EXPLORER di WIN XP, mentre il problema è stato risolto in VISTA!
Se trovi la soluzione sei un grande ed io compenserò il tuo sforzo per averla trovata.
Saluti.
October 23rd, 2008 15:20
Hello,
I congratulate you on your work, but I have to sub a difficult question, that if you manage to resolve you make a DONATION.
I need to make a symbolic link to the DESKTOP folder, but unfortunately after the fact you can not delete files or folders from DESKTOP due to a limitation of EXPLORER WIN XP, but the problem is resolved in VISTA!
If you find the solution you’re a big and I will compensate you for your effort have found.
Greetings.
November 8th, 2008 02:45
En el segundo párrafo pone:
“los enlaces simbólicos pueden apuntar a un archivo, un Mando de las Naciones Unidas, una carpeta o volumen, así como capaz de abarcar los sistemas de archivos.”
Pues yo, por mucho que lo intento no consigo apuntar a un Mando de las Naciones Unidas con MKLINK