Create Symlinks in Windows 10

Create Symlink in Windows 10Because Windows improved a lot over the recent years, I decided to give it another try. Therefore I installed Windows 10 in addition to my Mint Linux. Yes folks, that really happened 😀 . One of the first “again a beginner” – questions I stumbled upon, was how to create Symlinks in windows 10. 
The reason was, that Windows didn’t allow me to use a folder of my Nextcloud mount folder as a source for the lock screen slideshow. However it did allow folders under the standard picture folder. Under Linux this is a a predestined case to use a Symlink. So I ask myself, how I can create a Symlinks in Windows 10?

The Linux command would have been:

$> ln -s destination/path link/path

The corresponding counterpart for the Linux ln command in Windows 10 is the mklink command. Unfortunately thy syntax is almost the opposite of the Linux equivalent.

C:\Users\Bravehartk2\Pictures>mklink
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target

    /D      Creates a directory symbolic link.  Default is a 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.

Above all, the two operands for the link and the target path are twisted. That could be a little bit confusing for a former Linux user.

Finally here is the command that creates a symbolic link “Screensaver” inside my standard “Pictures” folder. It points to my Nextcloud folder “Images/Screensaver”

c:\Users\Bravehartk2\Pictures>mklink /D Screensaver ..\Nextcloud\Images\Screensaver 

Where the parameter \D specifies the Symlink as a directory.
The result should look like that:

symbolic link created for Screensaver <<===>> ..\Nextcloud\Images\Screensaver

c:\Users\Bravehartk2\Pictures>dir

 Directory of c:\Users\Bravehartk2\Pictures

20/08/2020  12:32    <DIR>          .
20/08/2020  12:32    <DIR>          ..
20/08/2020  12:32    <SYMLINKD>     Screensaver [..\Nextcloud\Images\Screensaver]

If you get the error message “You do not have sufficient privilege to perform this operation.”, you have to run the command prompt as administrator. Therefore you have to type cmd into the search field. Afterwards the command prompt app should be shown. Then you have to right-click on the app and select “Run as administrator”.

Finally, after setting the Symlink, I was able to just add the Screensaver Symlink as a source for the lock screen slideshow.

Use Powershell to create Symlinks in Windows 10

As you might know, Windows 10 has an alternative commandline app called PowerShell. has You can start it by hitting the Ctrl+R and type powershell and enter again.

The Syntax to create a Symlink via Powershell is:

New-Item -ItemType SymbolicLink -Path "Symlink/Path" -Target "Destination/Path"

For my concrete case it was the following command:

PS C:\Users\Bravehartk2\Pictures> New-Item -ItemType SymbolicLink -Path ".\Pictures\Sareensaver2" -Target "..\Nextcloud\Images\Screensaver\"                                                                       

As for the cmd command, it could be necessary to run the PowerShell as administrator.

Further information

Here you can find further information about creating Symlinks in Windows 10.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.