Windows Symlink

Windows Symlink

In computing, a symbolic link also called symlink or soft link. it is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symlinks, or symbolic links, are “virtual” files or folders which reference a physical file or folder located elsewhere, and are an important feature built in to many operating systems, including Linux and Windows. The Windows’ NTFS file system has supported symlinks since Windows Vista. A symlink is essentially a pointer to a file or folder located elsewhere, consumes little space and is very fast to create (compared to copying a file and its contents).

Because of this, developers often replace duplicate copies of shared files/folders with symlinks referencing physical files/folders. Replacing redundant copies of files can save a great deal of physical disk space, and significantly reduce the time taken to copy/backup/deploy/clone projects.


Use of Symlinks

In windows 7, 8, 10 and Vista all support symbolic links—also known as symlinks—that point to a file or folder on your system. You can create them using the Command Prompt or a third-party tool called Link Shell Extension. Symbolic links are basically advanced shortcuts. Create a symbolic link to an individual file or folder, and that link will appear to be the same as the file or folder to Windows even though it’s just a link pointing at the file or folder.
Symlinks are created either using the mklink command or the CreateSymbolicLink API
There is no change in how to call mklink. For users who have Developer Mode enabled, the mklink command will now successfully create a symlink if the user is not running as an administrator.
To enable the new behavior when using the CreateSymbolicLink API, there is an additional dwFlags option you will need to set:

mklink Syntax

command image

Parameters of mklink:


Guide to Create Symbolic Links with mklink:

create symbolic links image

You can create symbolic links using the mklink command in a Command Prompt window as Administrator. So you can follow these steps:

  • Open “Command Prompt” shortcut in your Start menu.
  • Right-click and select “Run as Administrator”.
  • On Windows 10’s Creators Update, you can use a normal Command Prompt window, without running it as an Administrator.
  • However, to do this without an Administrator Command Prompt window.
  • You must first enable Developer Mode from Settings > Update & Security > For Developers.
command prompt option image
  • Without any extra options, mklink creates a symbolic link to a file.
command image
  • The below command creates a symbolic, or “soft”, link at Link pointing to the file Target :
command image
  • Use /D when you want to create a soft link pointing to a directory. like so:
command image
  • Use /H when you want to create a hard link pointing to a file:
command image
  • Use /J to create a hard link pointing to a directory, also known as a directory junction:
command image
cmd command image

Hope this article is helpful to you.