Symlinks are pretty popular in Linux, you download your software into a folder with the version in the name (like mRemote-1.75.7012) then create a symlink called mRemote to that folder, so any references you make go to mRemote and if you update to the latest software you can simply update the symlink.

But how do you do such things in windows.. I actually didnt think you could until a work college pointed out you can (Thanks John!), with that a quick blog post so i don’t forget!

Create Symlink

Command Line

You can use the command line mklink, so for our above example you can use

mklink /J C:\Temp\mRemote C:\Temp\mRemote-1.75.7012

PowerShell

If we try and use the above command straight into PowerShell we get an annoying error (See below)
symlink

We can get around this using the below

cmd /c mklink /J C:\Temp\mRemote C:\Temp\mRemote-1.75.7012

But the better way is to use the New-Item function which has the -ItemType of SymbolicLink

New-Item -Path C:\Temp\mRemote -ItemType SymbolicLink -Value C:\Temp\mRemote-1.75.7012

After you run the code you will now see a new folder with an arrow icon bottom left, if you go into properties of the folder you will see it shows the target

symlink2

Update Symlink

Command Line

Now if we get a new version of mRemote say mRemote-1.75.7013 we need to delete the current symlink and create a new one:

rd c:\temp\mRemote
mklink /J C:\Temp\mRemote C:\Temp\mRemote-1.75.7012

PowerShell

To update via PowerShell we can just use the force command to update without the new to delete and recreate

New-Item -Path C:\Temp\mRemote -ItemType SymbolicLink -Value C:\Temp\mRemote-1.75.7013 -Force

As you can see from the picture below, we now have our mRemote folder pointing to the new 7013 version.

symlink3

Remove Symlink

Command Line

As we did in the update, we just rd to delete the folder

rd c:\temp\mRemote

PowerShell

To remove a symlink in PowerShell we just Remove-Item with the -Force switch

Remove-Item C:\Temp\mRemote -Force
Advertisements