Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change target for symbolic link in windows

How can I change target of already existing symbolic link. Any solution would work: console, powershell,etc.

Important think is to make this change atomically so solution to delete link and then create a new one do not work for me.

like image 582
Eugeniu Torica Avatar asked Jul 02 '12 15:07

Eugeniu Torica


2 Answers

This seems to be possible with the ZwFsControlFile function using the FSCTL_SET_REPARSE_POINT control code. At least that's what I gleaned from how Far Manager does it via Process Monitor.

like image 84
Joey Avatar answered Sep 30 '22 05:09

Joey


You could use transactional NTFS. See the following functions:

  • CreateTransaction
  • DeleteFileTransacted
  • CreateSymbolicLinkTransacted
  • CommitTransaction

The downside is that MS are deprecating support for transactions. In particular transactions are not available in the new file system being introduced in Windows Server 2012.

like image 40
Harry Johnston Avatar answered Sep 30 '22 06:09

Harry Johnston