Windows symlink examples

Softlinks are useful in any operating system to shorten long, complicated path names like C:/user/foo/data to just C:/data. Set user permission to create symbolic links.

From Windows Command Prompt:

mklink LINK TARGET

For directories add the /d option

mklink /d LINK TARGET

Example: default GNU Make filename in MinGW is mingw32-make.exe, but we’d rather type make:

cd %SYSTEMDRIVE%\mingw\mingw64\bin

mklink make.exe mingw32-make.exe

Powershell symbolic link creation syntax is more verbose:

New-Item -ItemType SymbolicLink -Path "Link" -Target "Target"

For the same example as above:

cd $Env:SystemDrive\mingw\mingw64\bin

New-Item -ItemType SymbolicLink -Path "make.exe " -Target "mingw32-make.exe"

On Unix-like shell, softlinks are created like:

ln -s /media/myusbdrive/data ~/data

Notice that the order of target arguments are reversed between Windows and Unix-like shells.