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
  • 45,747
  • 43
  • 165
  • 205
Wes
  • 175
  • 7
  • 2
    It is not possible. – DavidPostill Mar 28 '15 at 22:21
  • You mean there are no alternatives that can best accomplish the goal, not even programmatically nor can you offer me a best practice that best accomplishes it? – Wes Mar 28 '15 at 22:31
  • By definition you cannot do what you want to do. – DavidPostill Mar 28 '15 at 22:40
  • I'm sure someone could write a program to repair broken links but to my knowledge, no one has . But that would still be a possibility. I'm sure it's possible, maybe impractical. – Wes Mar 28 '15 at 22:45
  • 1
    "I don't want to use drive letters or relative paths" -- is not possible. – DavidPostill Mar 28 '15 at 22:48
  • "I wanna be able to specify a target that won't break the shortcut when drive letters change." is not possible. – DavidPostill Mar 28 '15 at 22:49
  • "write a program to repair broken links" is so impractical it's impossible -- how would you know where the target of the broken link has has moved to (target could be a URL whch could be anywhere in cyberspace)? – DavidPostill Mar 28 '15 at 22:52
  • 2
    Rather than reposting nearly identical questions, it would be much better if you would edit your question to be clearer. Too many deleted questions risks hitting one of the system controls that will either limit or restrict you from posting further questions. If you feel that your earlier questions were low quality, then the "improve" or "edit" button underneath the question would have enabled you to make them better questions. – Mokubai Mar 28 '15 at 22:54
  • The best thing I can think of to accomplish my goal is a symbolic link that points to a drive letter, such that when drive letter changes I can point the link to the new drive letter. Or maybe a network drive that maps to a drive letter. Those wouldn't have been a bad suggestions, although I'd prefer something more robust but those would have been decent answers. – Wes Mar 28 '15 at 22:55
  • @Mokubai I deleted the second question because it was marked as a duplicate. I deleted my first question, because it was an all around bad question and no one was reading it anymore because it was old. I had to rephrase this one otherwise it would have been marked as a duplicate of my second question. – Wes Mar 28 '15 at 22:57
  • Related: http://superuser.com/questions/307955/how-do-windows-nt-based-operating-systems-address-devices – bwDraco Mar 28 '15 at 23:16
  • @DragonLord I'm familiar with this notation but it doesnt appear you can use these notations when specifying shortcut targets. – Wes Mar 28 '15 at 23:26
  • Why would a drive letter change (unless you are using removable media)? – LDC3 Mar 28 '15 at 23:48
  • @LDC3 I manage a couple dozen drives and they get automounted and I'd rather not keep track of them. – Wes Mar 28 '15 at 23:49
  • When the drives get mounted, can they execute a batch file from the drive? The batch file could set an environment variable which is used to set the link (or path). – LDC3 Mar 29 '15 at 01:21

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
  • 153,128
  • 77
  • 353
  • 394
  • That link talks only about shell shortcuts; how does it apply to filesystem-level symlinks or junctions? – u1686_grawity Mar 28 '15 at 23:09
  • @DavidPostill Symbolic links or mapped network drives would actually accomplish what I'm looking for. I mean you change the letters on volumes then all you have to do is point the links to another letter. And you can use these links in shortcuts. Although I was hoping for a better solution than these ones, certainly a better one than the suggestion "it is not possible". – Wes Mar 28 '15 at 23:09
  • @grawity junctions was added to the question **after** I answered. – DavidPostill Mar 29 '15 at 05:08
  • @wes answer updated to give solution using a symbolic link – DavidPostill Mar 29 '15 at 21:37
  • [**mountvol**](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/mountvol) can be used to find out the GUID of the partition, e.g. `mountvol X: /L` – Cristian Ciupitu May 14 '19 at 23:18
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,233
  • 13
  • 28