Define a fixed letter for an external USB drive Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fmildemberger
Posts: 29
Joined: 22 Jan 2014, 10:31

Define a fixed letter for an external USB drive

07 Aug 2023, 06:29

How to define a fixed letter for an external usb drive?
I would like that when connecting an external hdd, a letter is automatically assigned


[Mod edit: Replaced original subject line: “DEFINE A FIXED LETTER POR [sic] A [sic] EXTERNAL USB DRIVE !” Please don’t use all caps in the future.]
Last edited by fmildemberger on 23 Oct 2023, 06:00, edited 1 time in total.
User avatar
boiler
Posts: 17279
Joined: 21 Dec 2014, 02:44

Re: DEFINE A FIXED LETTER POR A EXTERNAL USB DRIVE !  Topic is solved

07 Aug 2023, 06:35

NO NEED TO YELL.

Assuming this can be accomplished in AHK, are you really using v2? You posted in the main section of the forum, which is now for v2.
iseahound
Posts: 1459
Joined: 13 Aug 2016, 21:04
Contact:

Re: Define a fixed letter for an external USB drive

07 Aug 2023, 10:07

I used to do the same thing, but realized it was pointless since every other computer would assign a different letter. Instead I now use the following 2 functions:

Code: Select all

DriveLabel(label) {
   Loop Parse, DriveGetList()
      if label = DriveGetLabel(A_LoopField ":")
         return A_LoopField ":"
   throw Error("Drive label " label " not found.")
}

DriveIndex(index, omitLabel := ["Heritage"]) {
   i := 0
   Loop Parse, DriveGetList()
      if A_LoopField != SubStr(A_WinDir, 1, 1)
         if "Heritage" != DriveGetLabel(A_LoopField ":")
            if index = ++i
               return A_LoopField ":"
   throw Error("Drive index not found.")
}

Run DriveIndex(1) ; This avoids the C: Drive, and will be your D: drive or E: drive or F: drive, etc.
Run DriveLabel("My USB Drive") ; Open the usb drive called "My USB Drive"
If you just want to assign a drive letter to your USB drive, go to Computer Management > Disk Management, click on your drive, and Assign a letter to this drive. You must do this for every computer you have access to.
User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: Define a fixed letter for an external USB drive

07 Aug 2023, 10:45

@fmildemberger

Outside AHK, check a tool called USBDLM.
So much universe, and so little time. GNU Sir Terry.
fmildemberger
Posts: 29
Joined: 22 Jan 2014, 10:31

Re: DEFINE A FIXED LETTER POR A EXTERNAL USB DRIVE !

12 Sep 2023, 13:42

boiler wrote:
07 Aug 2023, 06:35
NO NEED TO YELL.

Assuming this can be accomplished in AHK, are you really using v2? You posted in the main section of the forum, which is now for v2.
No im using v1.1.36.01....
gregster
Posts: 9096
Joined: 30 Sep 2013, 06:48

Re: DEFINE A FIXED LETTER POR A EXTERNAL USB DRIVE !

12 Sep 2023, 13:45

fmildemberger wrote:
12 Sep 2023, 13:42
No im using v1.1.36.01....
I moved your topic to the correct subforum.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 172 guests