-3

I have an external drive. When I plug it in, sometimes it comes up as d: and sometimes as e:. I presume depending on whether I've plugged anything else in lately, like a USB drive, but whatever. I would like to have a fixed name to files on this drive. Can I map a UNC name to the drive, so that whether it's D: or E:, it will always be \foo or \mycomputer\foo or whatever?

I see someone referred me to a question about how to map network drives to UNC names. Thanks, but that's not what I'm looking for. I know how to map a specific drive letter to a UNC name. But in this case, the drive letter can change each time I plug the drive in. What I want to know is, is there a way to map a device name to a UNC name? Like, I've named the drive "pergamum". (Because it's my library and there was a great ancient library in Pergamum, get it? My network drive I call Alexandria.) So what I'm looking for is a way that whenever I plug it in, it becomes \\pergamum (or whatever, the exact name doesn't matter), regardless of whether it's on D: or E:

I see I've gotten the same suggested "does this answer your question" a second time. Please read my second paragraph in which I attempt to explain why that doesn't answer my question. I'm not asking how to map a UNC name to a drive LETTER. I'm asking how to map a UNC name to a drive NAME. Or some other identifier of the drive that would remain constant even if the drive letter changes.

Sigh. I have already edited the question twice to explain why " How do i map network drive with User Credentials" does not answer my question. I'll state it a third time: I'm looking for a way to map a removable external drive to a UNC name, where the drive letter might change every time the drive is connected. I AM NOT ASKING HOW TO MAP A FIXED DRIVE LETTER TO A UNC NAME!!! Does anyone actually read the question before voting to close? I understand that the first time this was suggested, perhaps my question was not clearly enough worded. But I've now spelled out, I think quite clearly, why that does not answer my question. If the answer is, "There is no out-of-the-box way to do this", okay, fine. But don't tell me there's a way and then point me to an answer that does not, in fact, answer my question.

Jay
  • 26,876
  • 10
  • 61
  • 112
  • 2
    Does this answer your question? [How do i map network drive with User Credentials](https://stackoverflow.com/questions/4487584/how-do-i-map-network-drive-with-user-credentials) – SomeWittyUsername Dec 17 '22 at 22:26
  • @SomeWittyUsername Thanks, but not quite. I've updated my question to clarify. – Jay Dec 18 '22 at 03:42
  • "Does anyone actually read the question before voting to close?"—this question is clearer now, but it's still off topic since it has nothing to do with programming. You might have better luck on [su] (though please make sure to read their "on topic" and "how to ask" pages before posting there). – ChrisGPT was on strike Dec 19 '22 at 18:39
  • @chris Well, I saw it as "having to do with programming" because I want to access the external drive from a program without having to ask the user what the drive letter is every time. But okay, But yeah, if you want to say, "you are asking how to use an OS feature to accomplish X rather than writing code, and that is out of scope", okay. I'd say that's a quibble but okay. – Jay Dec 20 '22 at 00:31

1 Answers1

0

Any solution must be able to identify your specific drive based on some unique piece of information that sets it apart from other drives that could've been plugged in. I don't think there is an out-of-the-box automatic solution. One solution can be to create a scheduled script (use Windows Task Scheduler) that hooks on device attach event and performs some checks that you have defined. E.g., put a file with a unique hash in the root folder of your drive and let the scheduled script read it upon drive attach. Once the drive is verified, the script can create a static alias that you define for it, like this: https://superuser.com/questions/528836/map-network-drive-and-provide-an-alias.

SomeWittyUsername
  • 18,025
  • 3
  • 42
  • 85
  • I was -- perhaps naively -- hoping that the device name could serve as such an identifier. Sure, nothing guarantees that I don't have two external drives and give them the same name. But that could be a feature rather than a bug, like if I buy a newer drive to replace the old one, that it would magically pick up the UNC name. Anyway, yes, I suppose I could write a script or a small program. But then I'd have to run it whenever I mounted the drive, at which point I may as well just do a normal drive mapping after seeing what drive letter it gets. ... – Jay Dec 18 '22 at 21:45
  • ... Okay, it takes a couple of minutes, supreme laziness to not want to I suppose. – Jay Dec 18 '22 at 21:45
  • Can a scheduled script fire every time a device is attached? Only way I've ever set one up is to run at a specific time or time interval. – Jay Dec 18 '22 at 21:47
  • Task scheduler can fire a script upon event. You provide the scheduler with the relevant event id. I assume that mounting a new drive will result in a distinct event that you can piggy back on (just plug it in and check the event viewer for a new event to identify the id). In the script you can indeed probably just check if you have access to your UNC path once the drive was mounted (if you don't, it's not the correct drive). – SomeWittyUsername Dec 19 '22 at 18:30