Any way to specify e.g. \\?\Volume{f993747a-5d7a-4de1-a97a-c20c1af1ba02}\path\to\target.txt as the target of a symlink? Or does the absolute path always require a drive letter?
-
1Sounds like something you can find out by just trying... What stopped you from doing that? – LPChip Mar 29 '15 at 19:13
-
I did. But I didn't read anywhere that it wasn't possible, so I was wondering if there was some fancy prefix I'm supposed to use or something. Or someone can just tell me if it is or isn't possible and not be a smartass. – Wes Mar 29 '15 at 19:23
-
1is this not just a dupe of http://superuser.com/questions/895229/can-i-create-a-shortcut-which-points-to-a-specific-drive-regardless-of-its-drive ? – Tetsujin Mar 29 '15 at 19:30
-
No because that question only concerns shortcuts not symbolic links. – Wes Mar 29 '15 at 19:33
2 Answers
Can an NTFS symlink have a volume guid target?
You can use mklink to create a symbolic link of the form \\?\Volume{f993747a-5d7a-4de1-a97a-c20c1af1ba02}\path\to\target.txt
c:
md \test
cd \test
mklink testlink \\?\Volume{d1a54614-9369-11e4-b7ab-ccaf78b24c0a}\test\test.txt
Now the directory test contains a symbolic link (which in my case points to a file f:\test\test.txt on an external drive).
C:\test>dir
Volume in drive C has no label.
Volume Serial Number is C8D0-DF1E
Directory of C:\test
29/03/2015 23:24 <DIR> .
29/03/2015 23:24 <DIR> ..
29/03/2015 23:17 <SYMLINK> testlink [\\?\Volume{d1a54614-9369-11e4-b7ab-ccaf78b24c0a}\test\test.txt]
1 File(s) 0 bytes
2 Dir(s) 248,410,976,256 bytes free
...
C:\test>type testlink
this file is test.txt
C:\test>
...
C:\test>type f:\test\test.txt
this file is test.txt
C:\test>
Note
- This only works if you try to dereference the link from the command prompt, but not if you try to access it from the explorer interface.
Further Reading
- An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
- mklink - Create a symbolic link to a directory or a file, or create a hard file link or directory junction.
- 153,128
- 77
- 353
- 394
-
The link gets created to be sure, but if I try to access it in Windows explorer nothing happens. So I guess the answer is yes only if you try to access it from the command line but no if you try to do it from the UI. – Wes Mar 29 '15 at 22:37
-
Unless you find otherwise to my previous comment, I'll modify your answer to state only from the command line and vote it the answer. – Wes Mar 29 '15 at 22:43
I have noticed only a single issue after years of using 10,000's of cross-drive hard links extensively. How significant it is will depend on your specific situation. Note that my application is using hard-links ("directory junctions," created with linkd.exe) only, so the following may or may not apply to the other types of symlink.
The only issue I've had is that chkdsk behaves badly in rare cases. If chkdsk.exe runs automatically on boot in response to a drive being previously shut down with a pending dirty flag, then it seems to remove all the cross-drive junctions in some cases. Besides removing the junctions, however the chkdsk.exe bug doesn't corrupt anything.
There are various workarounds and strategies for addressing the chkdsk.exe problem, which are beyond the scope of the original question, so suffice it to say that yes it works... with the one caveat I've encountered having been mentioned.
- 1,465
- 12
- 20