Jump to content

Removable Drive Letter Mapping


Recommended Posts

Guest John Gregory
Posted

Removable Drive Letter Mapping

 

Is there a way to force the drive letter assignment for removable USB

drives? (in the same manner as mapping network drives perhaps?)

 

I frequently use two removable drives, a USB thumb drive with transfer

files, and a USB hard drive for back-up purposes. I use batch files to

transfer frequently used work files, and another program do perform backups,

however they are dependent upon drive letter assignments to work properly.

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

 

"John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

news:66CFD834-65CE-4B05-9FE0-7609FF823DF6@microsoft.com...

> Removable Drive Letter Mapping

>

> Is there a way to force the drive letter assignment for removable USB

> drives? (in the same manner as mapping network drives perhaps?)

>

> I frequently use two removable drives, a USB thumb drive with transfer

> files, and a USB hard drive for back-up purposes. I use batch files to

> transfer frequently used work files, and another program do perform

> backups,

> however they are dependent upon drive letter assignments to work properly.

>

 

Have a look at USBDLM: http://www.uwe-sieber.de/usbdlm_e.html

Guest John Gregory
Posted

Re: Removable Drive Letter Mapping

 

I looked at the posted URL, the program discussed does not completely solve

my problem. It still seems to map the drives in the order they are installed.

 

What I would like, is something to put on a particular USB drive, in an

autorun file, that would map that drive to a specific letter regardless of

what computer it is installed into, or what order it is installed. Something

like the "net use" network mapping command.

 

Does something like this already exist?

 

"Pegasus (MVP)" wrote:

>

> "John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

> news:66CFD834-65CE-4B05-9FE0-7609FF823DF6@microsoft.com...

> > Removable Drive Letter Mapping

> >

> > Is there a way to force the drive letter assignment for removable USB

> > drives? (in the same manner as mapping network drives perhaps?)

> >

> > I frequently use two removable drives, a USB thumb drive with transfer

> > files, and a USB hard drive for back-up purposes. I use batch files to

> > transfer frequently used work files, and another program do perform

> > backups,

> > however they are dependent upon drive letter assignments to work properly.

> >

>

> Have a look at USBDLM: http://www.uwe-sieber.de/usbdlm_e.html

>

>

>

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

You could try the script below. Here is what you should do:

1. Copy & paste the code into c:\Windows\USBDrive.vbs.

2. Line 7 sets a polling interval of 10 seconds. Set it to 5

for your tests, then return it to 10.

2. Modify Line 8 to reflect the number of flash disks you wish to monitor.

3. Modify Line 11 to reflect your first USB disk.

4. Modify / insert extra lines for your remaining disks.

5. Each line starts with a line number. Unwrap those lines

that don't, then remove the line numbers.

6. Start a Command Prompt (Start / Run / cmd {OK}

7. Type this command: cscript c:\windows\USBDrive.vbs{Enter}

8. Connect one of your USB drives and watch what happens. Make

sure to wait 5 seconds before removing/inserting a flash disk.

9. Press Ctrl+Break to terminate the program.

 

To start the program automatically, use the Task Scheduler

to launch it at boot time.

 

1. '----------------------------------------------------

2. 'USB Drive letter changer

3. 'Code based on an idea by the Microsoft Scripting Guy

4. 'Version 1.0

5. '3 March 2008 FNL

6. '----------------------------------------------------

7. Const Interval = 10 'Interval between polls

8. Const disks = 2

9. Dim USB()

10. ReDim USB(disks)

11. USB(0) = "G: LARGE USB" 'Must be in upper case!

12. USB(1) = "H: SMALL USB" 'Must be in upper case!

13. Const command = "mountvol.exe "

14.

15. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

16. Set oFSO = CreateObject("Scripting.FileSystemObject")

17. Set objWshShell = WScript.CreateObject("WScript.Shell")

18.

19. Set colEvents = objWMIService.ExecNotificationQuery _

20. ("Select * From __InstanceOperationEvent Within " & Interval _

21. & " Where TargetInstance isa 'Win32_LogicalDisk'")

22.

23. Do While True

24. Set objEvent = colEvents.NextEvent

25. If objEvent.TargetInstance.DriveType = 2 Then

26. If objEvent.Path_.Class = "__InstanceCreationEvent" Then

27. ALetter = objEvent.TargetInstance.DeviceID

28. Set oVol = oFSO.GetDrive(ALetter)

29. Label = UCase(oVol.VolumeName)

30. WLetter = ""

31. For i = 0 To disks - 1

32. If instr(USB(i), Label) > 0 then WLetter = Left(USB(i), 2)

33. Next

34. If (Not WLetter = ALetter) And (Not WLetter = "") Then

35. Set objExec = objWshShell.Exec (command & ALetter & " /L")

36. Vol = objExec.StdOut.ReadLine

37. Set objExec = objWshShell.Exec (command & ALetter & " /D")

38. Set objExec = objWshShell.Exec (command & WLetter & " " & Vol)

39. WScript.Echo "Drive letter changed from " & ALetter & " to " &

WLetter

40. End If

41. End If

42. End If

43. Loop

 

 

"John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

news:8B0CC6EC-ED68-487C-8E37-B43A33DB2EC6@microsoft.com...

>I looked at the posted URL, the program discussed does not completely solve

> my problem. It still seems to map the drives in the order they are

> installed.

>

> What I would like, is something to put on a particular USB drive, in an

> autorun file, that would map that drive to a specific letter regardless of

> what computer it is installed into, or what order it is installed.

> Something

> like the "net use" network mapping command.

>

> Does something like this already exist?

>

Guest John Gregory
Posted

Re: Removable Drive Letter Mapping

 

The script worked fine on the first USB drive (a USB 2 Gb flash drive), but

it would not work on the second USB drive (a USB 160 Gb hard drive).

 

The drive names are: "TRAVELDRIVE" and "JJG_160_GB"

 

Any Ideas?

 

"Pegasus (MVP)" wrote:

> You could try the script below. Here is what you should do:

> 1. Copy & paste the code into c:\Windows\USBDrive.vbs.

> 2. Line 7 sets a polling interval of 10 seconds. Set it to 5

> for your tests, then return it to 10.

> 2. Modify Line 8 to reflect the number of flash disks you wish to monitor.

> 3. Modify Line 11 to reflect your first USB disk.

> 4. Modify / insert extra lines for your remaining disks.

> 5. Each line starts with a line number. Unwrap those lines

> that don't, then remove the line numbers.

> 6. Start a Command Prompt (Start / Run / cmd {OK}

> 7. Type this command: cscript c:\windows\USBDrive.vbs{Enter}

> 8. Connect one of your USB drives and watch what happens. Make

> sure to wait 5 seconds before removing/inserting a flash disk.

> 9. Press Ctrl+Break to terminate the program.

>

> To start the program automatically, use the Task Scheduler

> to launch it at boot time.

>

> 1. '----------------------------------------------------

> 2. 'USB Drive letter changer

> 3. 'Code based on an idea by the Microsoft Scripting Guy

> 4. 'Version 1.0

> 5. '3 March 2008 FNL

> 6. '----------------------------------------------------

> 7. Const Interval = 10 'Interval between polls

> 8. Const disks = 2

> 9. Dim USB()

> 10. ReDim USB(disks)

> 11. USB(0) = "G: LARGE USB" 'Must be in upper case!

> 12. USB(1) = "H: SMALL USB" 'Must be in upper case!

> 13. Const command = "mountvol.exe "

> 14.

> 15. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

> 16. Set oFSO = CreateObject("Scripting.FileSystemObject")

> 17. Set objWshShell = WScript.CreateObject("WScript.Shell")

> 18.

> 19. Set colEvents = objWMIService.ExecNotificationQuery _

> 20. ("Select * From __InstanceOperationEvent Within " & Interval _

> 21. & " Where TargetInstance isa 'Win32_LogicalDisk'")

> 22.

> 23. Do While True

> 24. Set objEvent = colEvents.NextEvent

> 25. If objEvent.TargetInstance.DriveType = 2 Then

> 26. If objEvent.Path_.Class = "__InstanceCreationEvent" Then

> 27. ALetter = objEvent.TargetInstance.DeviceID

> 28. Set oVol = oFSO.GetDrive(ALetter)

> 29. Label = UCase(oVol.VolumeName)

> 30. WLetter = ""

> 31. For i = 0 To disks - 1

> 32. If instr(USB(i), Label) > 0 then WLetter = Left(USB(i), 2)

> 33. Next

> 34. If (Not WLetter = ALetter) And (Not WLetter = "") Then

> 35. Set objExec = objWshShell.Exec (command & ALetter & " /L")

> 36. Vol = objExec.StdOut.ReadLine

> 37. Set objExec = objWshShell.Exec (command & ALetter & " /D")

> 38. Set objExec = objWshShell.Exec (command & WLetter & " " & Vol)

> 39. WScript.Echo "Drive letter changed from " & ALetter & " to " &

> WLetter

> 40. End If

> 41. End If

> 42. End If

> 43. Loop

>

>

> "John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

> news:8B0CC6EC-ED68-487C-8E37-B43A33DB2EC6@microsoft.com...

> >I looked at the posted URL, the program discussed does not completely solve

> > my problem. It still seems to map the drives in the order they are

> > installed.

> >

> > What I would like, is something to put on a particular USB drive, in an

> > autorun file, that would map that drive to a specific letter regardless of

> > what computer it is installed into, or what order it is installed.

> > Something

> > like the "net use" network mapping command.

> >

> > Does something like this already exist?

> >

>

>

>

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

I can't tell without being there . . . However, you can

do your own debugging, by adding some lines to the

code as follows:

23. Do While True

24. Set objEvent = colEvents.NextEvent

25. If objEvent.TargetInstance.DriveType = 2 Then

26. If objEvent.Path_.Class = "__InstanceCreationEvent" Then

27. ALetter = objEvent.TargetInstance.DeviceID

28. Set oVol = oFSO.GetDrive(ALetter)

29. Label = UCase(oVol.VolumeName)

29a. wscript.echo "Drive Letter=" & ALetter & "xxx"

29b. wscript.echo "Volume Label=" & Label & "xxx"

 

Now do this:

1. Kill cscript.exe via the Task Manager or with taskkill.exe.

2. Open a Command Prompt.

3. Launch the script manually: cscript c:\windows\USBDrive.vbs

4. Insert your 160 GByte flash drive and watch the screen.

 

Remember to wait for at least "Interval" seconds between

insertions and removals.

 

 

"John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

news:020084E1-498F-4FD9-9245-2AABDEA0B112@microsoft.com...

> The script worked fine on the first USB drive (a USB 2 Gb flash drive),

> but

> it would not work on the second USB drive (a USB 160 Gb hard drive).

>

> The drive names are: "TRAVELDRIVE" and "JJG_160_GB"

>

> Any Ideas?

>

> "Pegasus (MVP)" wrote:

>

>> You could try the script below. Here is what you should do:

>> 1. Copy & paste the code into c:\Windows\USBDrive.vbs.

>> 2. Line 7 sets a polling interval of 10 seconds. Set it to 5

>> for your tests, then return it to 10.

>> 2. Modify Line 8 to reflect the number of flash disks you wish to

>> monitor.

>> 3. Modify Line 11 to reflect your first USB disk.

>> 4. Modify / insert extra lines for your remaining disks.

>> 5. Each line starts with a line number. Unwrap those lines

>> that don't, then remove the line numbers.

>> 6. Start a Command Prompt (Start / Run / cmd {OK}

>> 7. Type this command: cscript c:\windows\USBDrive.vbs{Enter}

>> 8. Connect one of your USB drives and watch what happens. Make

>> sure to wait 5 seconds before removing/inserting a flash disk.

>> 9. Press Ctrl+Break to terminate the program.

>>

>> To start the program automatically, use the Task Scheduler

>> to launch it at boot time.

>>

>> 1. '----------------------------------------------------

>> 2. 'USB Drive letter changer

>> 3. 'Code based on an idea by the Microsoft Scripting Guy

>> 4. 'Version 1.0

>> 5. '3 March 2008 FNL

>> 6. '----------------------------------------------------

>> 7. Const Interval = 10 'Interval between polls

>> 8. Const disks = 2

>> 9. Dim USB()

>> 10. ReDim USB(disks)

>> 11. USB(0) = "G: LARGE USB" 'Must be in upper case!

>> 12. USB(1) = "H: SMALL USB" 'Must be in upper case!

>> 13. Const command = "mountvol.exe "

>> 14.

>> 15. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

>> 16. Set oFSO = CreateObject("Scripting.FileSystemObject")

>> 17. Set objWshShell = WScript.CreateObject("WScript.Shell")

>> 18.

>> 19. Set colEvents = objWMIService.ExecNotificationQuery _

>> 20. ("Select * From __InstanceOperationEvent Within " & Interval _

>> 21. & " Where TargetInstance isa 'Win32_LogicalDisk'")

>> 22.

>> 23. Do While True

>> 24. Set objEvent = colEvents.NextEvent

>> 25. If objEvent.TargetInstance.DriveType = 2 Then

>> 26. If objEvent.Path_.Class = "__InstanceCreationEvent" Then

>> 27. ALetter = objEvent.TargetInstance.DeviceID

>> 28. Set oVol = oFSO.GetDrive(ALetter)

>> 29. Label = UCase(oVol.VolumeName)

>> 30. WLetter = ""

>> 31. For i = 0 To disks - 1

>> 32. If instr(USB(i), Label) > 0 then WLetter = Left(USB(i), 2)

>> 33. Next

>> 34. If (Not WLetter = ALetter) And (Not WLetter = "") Then

>> 35. Set objExec = objWshShell.Exec (command & ALetter & " /L")

>> 36. Vol = objExec.StdOut.ReadLine

>> 37. Set objExec = objWshShell.Exec (command & ALetter & " /D")

>> 38. Set objExec = objWshShell.Exec (command & WLetter & " " & Vol)

>> 39. WScript.Echo "Drive letter changed from " & ALetter & " to " &

>> WLetter

>> 40. End If

>> 41. End If

>> 42. End If

>> 43. Loop

>>

>>

>> "John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

>> news:8B0CC6EC-ED68-487C-8E37-B43A33DB2EC6@microsoft.com...

>> >I looked at the posted URL, the program discussed does not completely

>> >solve

>> > my problem. It still seems to map the drives in the order they are

>> > installed.

>> >

>> > What I would like, is something to put on a particular USB drive, in an

>> > autorun file, that would map that drive to a specific letter regardless

>> > of

>> > what computer it is installed into, or what order it is installed.

>> > Something

>> > like the "net use" network mapping command.

>> >

>> > Does something like this already exist?

>> >

>>

>>

>>

Guest John Gregory
Posted

Re: Removable Drive Letter Mapping

 

I modified the script, and followed your instructions. The flash drive is

remapped, with no further action. The USB hard drive is mapped normally, and

does not appear to be affected by the script. The following is the output:

 

C:\>cscript c:\windows\USBDrive.vbs

Microsoft ® Windows Script Host Version 5.6

Copyright © Microsoft Corporation 1996-2001. All rights reserved.

 

Drive Letter=E:xxx

Volume Label=TRAVELDRIVExxx

Drive letter changed from E: to X:

Drive Letter=X:xxx

Volume Label=TRAVELDRIVExxx

 

I connected the other USB drive here, but noting happend for a few minutes

and I ended the script

 

^C

 

I disconnected all removable drives and tried again.

 

C:\>cscript c:\windows\USBDrive.vbs

Microsoft ® Windows Script Host Version 5.6

Copyright © Microsoft Corporation 1996-2001. All rights reserved.

 

Drive Letter=X:xxx

Volume Label=TRAVELDRIVExxx

 

 

"Pegasus (MVP)" wrote:

> I can't tell without being there . . . However, you can

> do your own debugging, by adding some lines to the

> code as follows:

> 23. Do While True

> 24. Set objEvent = colEvents.NextEvent

> 25. If objEvent.TargetInstance.DriveType = 2 Then

> 26. If objEvent.Path_.Class = "__InstanceCreationEvent" Then

> 27. ALetter = objEvent.TargetInstance.DeviceID

> 28. Set oVol = oFSO.GetDrive(ALetter)

> 29. Label = UCase(oVol.VolumeName)

> 29a. wscript.echo "Drive Letter=" & ALetter & "xxx"

> 29b. wscript.echo "Volume Label=" & Label & "xxx"

>

> Now do this:

> 1. Kill cscript.exe via the Task Manager or with taskkill.exe.

> 2. Open a Command Prompt.

> 3. Launch the script manually: cscript c:\windows\USBDrive.vbs

> 4. Insert your 160 GByte flash drive and watch the screen.

>

> Remember to wait for at least "Interval" seconds between

> insertions and removals.

>

>

> "John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

> news:020084E1-498F-4FD9-9245-2AABDEA0B112@microsoft.com...

> > The script worked fine on the first USB drive (a USB 2 Gb flash drive),

> > but

> > it would not work on the second USB drive (a USB 160 Gb hard drive).

> >

> > The drive names are: "TRAVELDRIVE" and "JJG_160_GB"

> >

> > Any Ideas?

> >

> > "Pegasus (MVP)" wrote:

> >

> >> You could try the script below. Here is what you should do:

> >> 1. Copy & paste the code into c:\Windows\USBDrive.vbs.

> >> 2. Line 7 sets a polling interval of 10 seconds. Set it to 5

> >> for your tests, then return it to 10.

> >> 2. Modify Line 8 to reflect the number of flash disks you wish to

> >> monitor.

> >> 3. Modify Line 11 to reflect your first USB disk.

> >> 4. Modify / insert extra lines for your remaining disks.

> >> 5. Each line starts with a line number. Unwrap those lines

> >> that don't, then remove the line numbers.

> >> 6. Start a Command Prompt (Start / Run / cmd {OK}

> >> 7. Type this command: cscript c:\windows\USBDrive.vbs{Enter}

> >> 8. Connect one of your USB drives and watch what happens. Make

> >> sure to wait 5 seconds before removing/inserting a flash disk.

> >> 9. Press Ctrl+Break to terminate the program.

> >>

> >> To start the program automatically, use the Task Scheduler

> >> to launch it at boot time.

> >>

> >> 1. '----------------------------------------------------

> >> 2. 'USB Drive letter changer

> >> 3. 'Code based on an idea by the Microsoft Scripting Guy

> >> 4. 'Version 1.0

> >> 5. '3 March 2008 FNL

> >> 6. '----------------------------------------------------

> >> 7. Const Interval = 10 'Interval between polls

> >> 8. Const disks = 2

> >> 9. Dim USB()

> >> 10. ReDim USB(disks)

> >> 11. USB(0) = "G: LARGE USB" 'Must be in upper case!

> >> 12. USB(1) = "H: SMALL USB" 'Must be in upper case!

> >> 13. Const command = "mountvol.exe "

> >> 14.

> >> 15. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

> >> 16. Set oFSO = CreateObject("Scripting.FileSystemObject")

> >> 17. Set objWshShell = WScript.CreateObject("WScript.Shell")

> >> 18.

> >> 19. Set colEvents = objWMIService.ExecNotificationQuery _

> >> 20. ("Select * From __InstanceOperationEvent Within " & Interval _

> >> 21. & " Where TargetInstance isa 'Win32_LogicalDisk'")

> >> 22.

> >> 23. Do While True

> >> 24. Set objEvent = colEvents.NextEvent

> >> 25. If objEvent.TargetInstance.DriveType = 2 Then

> >> 26. If objEvent.Path_.Class = "__InstanceCreationEvent" Then

> >> 27. ALetter = objEvent.TargetInstance.DeviceID

> >> 28. Set oVol = oFSO.GetDrive(ALetter)

> >> 29. Label = UCase(oVol.VolumeName)

> >> 30. WLetter = ""

> >> 31. For i = 0 To disks - 1

> >> 32. If instr(USB(i), Label) > 0 then WLetter = Left(USB(i), 2)

> >> 33. Next

> >> 34. If (Not WLetter = ALetter) And (Not WLetter = "") Then

> >> 35. Set objExec = objWshShell.Exec (command & ALetter & " /L")

> >> 36. Vol = objExec.StdOut.ReadLine

> >> 37. Set objExec = objWshShell.Exec (command & ALetter & " /D")

> >> 38. Set objExec = objWshShell.Exec (command & WLetter & " " & Vol)

> >> 39. WScript.Echo "Drive letter changed from " & ALetter & " to " &

> >> WLetter

> >> 40. End If

> >> 41. End If

> >> 42. End If

> >> 43. Loop

> >>

> >>

> >> "John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

> >> news:8B0CC6EC-ED68-487C-8E37-B43A33DB2EC6@microsoft.com...

> >> >I looked at the posted URL, the program discussed does not completely

> >> >solve

> >> > my problem. It still seems to map the drives in the order they are

> >> > installed.

> >> >

> >> > What I would like, is something to put on a particular USB drive, in an

> >> > autorun file, that would map that drive to a specific letter regardless

> >> > of

> >> > what computer it is installed into, or what order it is installed.

> >> > Something

> >> > like the "net use" network mapping command.

> >> >

> >> > Does something like this already exist?

> >> >

> >>

> >>

> >>

>

>

>

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

I see what you mean. In spite of the original article referring to

"Removable Drive", the code used appears to pick up flash

disks only. I'll have to dig a little deeper . . .

 

 

"John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

news:7F52B030-B6C6-40B8-95CC-8BC635B132A1@microsoft.com...

>I modified the script, and followed your instructions. The flash drive is

> remapped, with no further action. The USB hard drive is mapped normally,

> and

> does not appear to be affected by the script. The following is the

> output:

>

> C:\>cscript c:\windows\USBDrive.vbs

> Microsoft ® Windows Script Host Version 5.6

> Copyright © Microsoft Corporation 1996-2001. All rights reserved.

>

> Drive Letter=E:xxx

> Volume Label=TRAVELDRIVExxx

> Drive letter changed from E: to X:

> Drive Letter=X:xxx

> Volume Label=TRAVELDRIVExxx

>

> I connected the other USB drive here, but noting happend for a few minutes

> and I ended the script

>

> ^C

>

> I disconnected all removable drives and tried again.

>

> C:\>cscript c:\windows\USBDrive.vbs

> Microsoft ® Windows Script Host Version 5.6

> Copyright © Microsoft Corporation 1996-2001. All rights reserved.

>

> Drive Letter=X:xxx

> Volume Label=TRAVELDRIVExxx

>

>

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

Problem solved. Line 25 used to look like so:

25. If objEvent.TargetInstance.DriveType = 2 Then

 

Replace it with these two lines:

25. DType = objEvent.TargetInstance.DriveType

25a. If (DType = 2) Or (DType = 3) Then

 

Please let me know how you go.

 

 

"John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

news:7F52B030-B6C6-40B8-95CC-8BC635B132A1@microsoft.com...

>I modified the script, and followed your instructions. The flash drive is

> remapped, with no further action. The USB hard drive is mapped normally,

> and

> does not appear to be affected by the script. The following is the

> output:

>

> C:\>cscript c:\windows\USBDrive.vbs

> Microsoft ® Windows Script Host Version 5.6

> Copyright © Microsoft Corporation 1996-2001. All rights reserved.

>

> Drive Letter=E:xxx

> Volume Label=TRAVELDRIVExxx

> Drive letter changed from E: to X:

> Drive Letter=X:xxx

> Volume Label=TRAVELDRIVExxx

>

> I connected the other USB drive here, but noting happend for a few minutes

> and I ended the script

>

> ^C

>

> I disconnected all removable drives and tried again.

>

> C:\>cscript c:\windows\USBDrive.vbs

> Microsoft ® Windows Script Host Version 5.6

> Copyright © Microsoft Corporation 1996-2001. All rights reserved.

>

> Drive Letter=X:xxx

> Volume Label=TRAVELDRIVExxx

>

Guest John Gregory
Posted

Re: Removable Drive Letter Mapping

 

This works perfectly! Thank you for your help.

 

"Pegasus (MVP)" wrote:

> Problem solved. Line 25 used to look like so:

> 25. If objEvent.TargetInstance.DriveType = 2 Then

>

> Replace it with these two lines:

> 25. DType = objEvent.TargetInstance.DriveType

> 25a. If (DType = 2) Or (DType = 3) Then

>

> Please let me know how you go.

>

>

> "John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

> news:7F52B030-B6C6-40B8-95CC-8BC635B132A1@microsoft.com...

> >I modified the script, and followed your instructions. The flash drive is

> > remapped, with no further action. The USB hard drive is mapped normally,

> > and

> > does not appear to be affected by the script. The following is the

> > output:

> >

> > C:\>cscript c:\windows\USBDrive.vbs

> > Microsoft ® Windows Script Host Version 5.6

> > Copyright © Microsoft Corporation 1996-2001. All rights reserved.

> >

> > Drive Letter=E:xxx

> > Volume Label=TRAVELDRIVExxx

> > Drive letter changed from E: to X:

> > Drive Letter=X:xxx

> > Volume Label=TRAVELDRIVExxx

> >

> > I connected the other USB drive here, but noting happend for a few minutes

> > and I ended the script

> >

> > ^C

> >

> > I disconnected all removable drives and tried again.

> >

> > C:\>cscript c:\windows\USBDrive.vbs

> > Microsoft ® Windows Script Host Version 5.6

> > Copyright © Microsoft Corporation 1996-2001. All rights reserved.

> >

> > Drive Letter=X:xxx

> > Volume Label=TRAVELDRIVExxx

> >

>

>

>

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

Thanks for the feedback.

 

"John Gregory" <JohnGregory@discussions.microsoft.com> wrote in message

news:CDD221E2-B7CD-426F-AAC6-F378F73CDB11@microsoft.com...

> This works perfectly! Thank you for your help.

>

Guest Uwe Sieber
Posted

Re: Removable Drive Letter Mapping

 

John Gregory wrote:

>>

>> Have a look at USBDLM: http://www.uwe-sieber.de/usbdlm_e.html

>>

> I looked at the posted URL, the program discussed does not completely solve

> my problem. It still seems to map the drives in the order they are installed.

 

Then it's not correctely installed or the USBDLM.INI

isn't correct.

> What I would like, is something to put on a particular USB drive, in an

> autorun file, that would map that drive to a specific letter regardless of

> what computer it is installed into, or what order it is installed. Something

> like the "net use" network mapping command.

 

You could create an additional drive letter using

the SUBST command.

 

subst U: .

 

This must be started from the drive in question, so

the . stands for the current folder which is the root

of the drive by default.

 

Adavantage: As with USBDLM it's not required to give the

user admin previleges.

 

Disadvantage: The additional drive letter should be deleted

when the drive is removed.

 

subst U: /D

 

 

Uwe

Posted

RE: Removable Drive Letter Mapping

 

Why does everyone (including MVPs) try to make things so complicated?

 

The following has worked without a single hitch since XP and continues to

work in Vista:

 

Insert your two USB drives > Click Start > Right Click Computers > Click on

Manage (wait) > Click on Disk Mangement (wait)> Right click the USB drive you

want to manage > Click Change Drive Letter and Paths > Select Change, then

assign the drive letter you want > Click OK and the USB drive letter is

changed and assigned, not only for this computer, but for any computer you

plug it into.

 

To change back again, just follow the above steps. It's provided for and

built into Windows XP and Vista.

 

Enjoy!

 

____________________

 

 

"John Gregory" wrote:

> Removable Drive Letter Mapping

>

> Is there a way to force the drive letter assignment for removable USB

> drives? (in the same manner as mapping network drives perhaps?)

>

> I frequently use two removable drives, a USB thumb drive with transfer

> files, and a USB hard drive for back-up purposes. I use batch files to

> transfer frequently used work files, and another program do perform backups,

> however they are dependent upon drive letter assignments to work properly.

>

Guest Pegasus \(MVP\)
Posted

Re: Removable Drive Letter Mapping

 

 

"Raas" <Raas@discussions.microsoft.com> wrote in message

news:EBEF27D2-6FE0-4757-A8C3-002716722F0C@microsoft.com...

> Why does everyone (including MVPs) try to make things so complicated?

>

.. . . because the OP's question implied that he wanted

a fixed drive letter without manual intervention. While

your method is the standard and well-known way of

setting drive letters, it is not automatic.

Guest John John
Posted

Re: Removable Drive Letter Mapping

 

Raas wrote:

> ... the USB drive letter is

> changed and assigned, not only for this computer, but for any computer you

> plug it into.

 

And what if the computer you plug it into has already assigned the drive

letter to another device, are you suggesting that the Mount Manager will

favour a newly plugged in drive and assign it a letter already assigned

to another device?

 

John

  • 7 months later...
Posted

Re: Removable Drive Letter Mapping

 

 

Try this vbs.

It checks the assigned drive letter and then replace it by X: :smile:

 

Const Removable = 1

 

I=""

dim filesys

Set filesys = CreateObject("Scripting.FileSystemObject")

set oFs = WScript.CreateObject("Scripting.FileSystemObject")

set oDrives = oFs.Drives

for each oDrive in oDrives

Select case oDrive.DriveType

Case removable

strComputer = "."

strOldDrive = odrive.DriveLetter & ":"

strNewDrive = "X:"

set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

set colVol = objWMI.ExecQuery("select * from Win32_Volume where Name =

'" & strOldDrive & "'\\'' (file://\\)")

if colVol.Count <> 1 then

WScript.Echo "Error: Volume not found."

else

for each objVol in colVol

objVol.DriveLetter = strNewDrive

objVol.Put_

' WScript.Echo "Successfully set drive letter for volume."

next

end if

 

End Select

next

 

 

--

bertv

×
×
  • Create New...