3

I noticed that I cannot use \\?\Volume{f993747a-5d7a-4de1-a97a-c20c1af1ba02}\path\to\target or \Device\HarddiskVolume5\path\to\target as shortcut targets—it won't work. It only works when I use drive letters in absolute paths. I don't want to use drive letters or relative paths.

Can I specify a target for a shortcut which won't break when drive letters change? Alternatively, can I create an NTFS reparse point (such as a junction point) to do this?

bwDraco
  • 46,683
Wes
  • 175

2 Answers2

3

Can I create a shortcut which points to a specific drive regardless of its drive letter?

I don't want to use drive letters or relative paths

The type of targets you wish to use (\?\Volume{f993747a-5d7a-4de1-a97a-c20c1af1ba02}\path\to\target or \Device\HarddiskVolume5\path\to\target) are not valid targets for a shortcut.

All of the valid targets for shortcuts must use one of the types specifed below.


Shortcut preference items allow you to configure a shortcut to a file system object (such as a file, folder, drive, share, or computer), a shell object (such as a printer, desktop item, or control panel item), or a URL (such as a Web page or an FTP site).

Source Configure a Shortcut Item


Alternatively, can I create an NTFS reparse point (such as a junction point) to do this?

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

DavidPostill
  • 162,382
0

It's a bit of a hack and possibly insecure, but you should be able to set up sharing on the root folder of the drive of interest (sharename floatdrive, say) with appropriate sharing permissions, and then construct all shortcuts/links using networking URL syntax on localhost:

\\localhost\floatdrive\folder\or\file\of\interest.txt

As long as Windows mounts the drive correctly, perhaps the share name will follow the drive no matter what drive letter it's been assigned. I unfortunately don't have a system on hand at the moment suitable to test this, though.

hBy2Py
  • 2,263