Click to Rate and Give Feedback
TechNet
TechNet Library
Windows
Windows Server
A-Z List
 Mklink
Mklink

Updated: April 25, 2007

Creates a symbolic link.

For examples of how to use this command, see Examples.

Syntax

mklink [[/d] | [/h] | [/j]] <Link> <Target>

Parameters

 

Parameter Description

/d

Creates a directory symbolic link. By default, mklink creates a file symbolic link.

/h

Creates a hard link instead of a symbolic link.

/j

Creates a Directory Junction.

<Link>

Specifies the name of the symbolic link that is being created.

<Target>

Specifies the path (relative or absolute) that the new symbolic link refers to.

/?

Displays help at the command prompt.

Examples

To create a symbolic link named MyDocs from the root directory to the \Users\User1\Documents directory, type:

mklink /d \MyDocs \Users\User1\Documents
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Why does this require admin privileges to run?      Genghis86 ... Thomas Lee   |   Edit   |   Show History
I am trying to run it in a directory where even a non-elevated user is allowed to write.
Genghis86 asks a good question      Thomas Lee   |   Edit   |   Show History
No idea why it required admin privileges but it might be to do with the confusion that making a hard link could cause. It doesn't seem that illogical (do you really want users making hard links everywhere which could cause backup loops, etc?). MS has always been a little shy over this feature, but I think I agree that if you have full control over a folder you should be able to mklink in that folder to another folder you also have access to.

At a very minimum, MS should explain this feature and why it's privileged.


Why higher privileges might be needed      Red!   |   Edit   |   Show History

I was testing an application which checked it's home running directory (it seems anyway) to know wether it's running; copying it to another directory worked in making the application start another process.

I though it would be clever to make a link to "sub" to "." (which actually works perfectly fine; and the application ran multiple times too), however when browsing in Explorer, for some reason it keeps expanding the infinite loop of symlinks! I even tried isolating the symlink in real directory; it still expanded it on it's own for unknown reasons.

So my guess is since it's so easy for someone to accidently do this, they wanted to protect "normal" users from using this - specially if using older applications unaware of the possibility of infinite loops...

Tags What's this?: Add a tag
Flag as ContentBug
SeCreateSymbolicLinkPrivilege is required      Petr Kadlec   |   Edit   |   Show History
Creation of symbolic links requires the SeCreateSymbolicLinkPrivilege (“Create symbolic links”), which is granted only to administrators by default (but you can change that using security policy). The stated reason for this requirement is: “This user right should only be assigned to trusted users. Symbolic links (symlinks) can expose security vulnerabilities in applications that aren't designed to handle symbolic links.” (See secpol.msc, or http://technet.microsoft.com/en-us/library/cc766301(WS.10).aspx)
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker