MKLink (Vista/Windows 7/2008)

Create a symbolic link to a directory or a file.

Syntax
      MKLINK [[/D] | [/H] | [/J]] Link Target

Key:

   /H     Create a hard link instead of a symbolic link.

   /J     Create a Directory Junction.

   Link   The new symbolic link name.

   Target The path (relative or absolute) that the new link refers to.

   /D     Create a Directory symbolic link. (default is file)

By default, only Administrators can create symbolic links. The security setting 'Create symbolic links' can be granted at: Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\

It is possible (but not advisable) to create links that point to each other in a loop, or a link that targets itself.

The three types of Link

Symbolic Links and Directory Junctions are implemented using reparse points, Hard Links are implemented with multiple file table entries that point to the same inode – the same as Unix hard links.

Symbolic link

Symbolic links (symlinks) can expose security vulnerabilities in applications that aren't designed to handle them. Windows Vista and later support Unix-style symlinks on the NTFS filesystem. A symlink can be an absolute path C:\Programs or a path relative to the link's location \Programs.

Deleting a Symbolic Link does not delete the contents of the target folder! (unlike Hard Junction links)
Symbolic links can span volumes and can use UNC paths.

Directory Junction

Windows 2000 and later support directory junctions on NTFS filesystems. Directory Junctions are always absolute and only point to directories, not files. Create junctions with MKLINK or download SysInternals junction for early Windows versions which do not have MKLINK.

Hard Link

All versions of Windows NT support Unix style hard links on NTFS filesystems. Create hard links with MKLINK on Vista and up. For XP use fsutil.

Examples:

Link for a file:
C:\> MKlink ss64.exe C:\Windows\system32\notepad.exe
C:\> Dir
C:\> Del ss64.exe

Link for a folder:
C:\> MKlink /D Apr C:\work\April
C:\> Dir
C:\> RD Apr

MKLINK is an internal command.

"And so its my assumption, I’m really up the junction" ~ Squeeze

Related Commands:

FSUTIL - Create Hard Junction Link
FSUTIL behavior set symlinkevalution - Allow/disable symbolic links
MOUNTVOL - Manage a volume mount point
Q205524 - How to create and manipulate NTFS junction points
LinkD - Create symbolic link (2003 Resource Kit)
NTFS_symbolic_link - Wikipedia
Junction - Create directory symbolic link (sysInternals)



Back to the Top

© Copyright SS64.com 1999-2013
Some rights reserved