How do I change target of symlink in windows

25

6

Is it possible to change the target of a symlink or junction in Windows? In Linux it can be modified with:

ln -f

Eugeniu Torica

Posted 2012-07-02T14:39:18.517

Reputation: 415

Answers

13

With Windows Link Shell Extension installed, you can right-click on the link in Windows Explorer and check the properties. There is a tab that allows you to change the link directly.

Sorry I can't say if this is possible without the extension installed as it is one of the first things I install after Windows.

The Windows command link tool mklink does not allow this.

There are, however, Windows equivalents for Linux commands. ln.exe is one:

Julian Knight

Posted 2012-07-02T14:39:18.517

Reputation: 13 389

mklink would be the Windows-integrated command for linking (symbolic and hard). – Jinxed – 2016-02-28T22:08:46.957

@Jinxed, I already said that mklink doesn't do what the OP asked. – Julian Knight – 2016-02-29T22:36:01.650

1The windows Methodology for changing the location of a softlink using MKLINK is to delete the link (Using RD /Q if a directory link, or Del /F /Q if a file link) and recreate it uisang MKLINK. eg RD /Q "C:\Link\Folder" && MKLINK /D "C:\Link\Folder" "C:\Some\New\Target\Folder" and Del /F /Q "C:\Link\File Link" && MKLINK "C:\Link\File Link.ext" "C:\Some\New\Target\File here.ext" This is also True for Junctions and Hard Links. – Ben Personick – 2019-05-14T15:33:42.460

This solution seems to work however I didn't test it thoroughly. – Eugeniu Torica – 2012-07-23T09:32:08.280

wow! Link Shell Extension, also notably, includes a Symbolic Link Driver for Windows XP among it's downloads. – n611x007 – 2013-03-27T11:50:02.930

3

Just remove and recreate the link. That's all that -f does in Linux anyway.

Also, here's a cool Windows Link Shell Extension.

David Cowden

Posted 2012-07-02T14:39:18.517

Reputation: 189

0

The method belo works for me in Windows 7

mklink TempLink NewTarget

copy /l /y TempLink OldLink

del TempLink

Gyan

Posted 2012-07-02T14:39:18.517

Reputation: 21 016