Re: Removable Drive Letter Mapping

Tech-Archive recommends: Speed Up your PC by fixing your registry



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@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8B0CC6EC-ED68-487C-8E37-B43A33DB2EC6@xxxxxxxxxxxxxxxx
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?




.



Relevant Pages

  • Re: Is it possible to use a USB Pen Drive as the swapfile?
    ... That sounds like the support for "flash ram enhanced hard drives". ... Indeed Vista can use USB drives, but not exactly as the swapfile. ... Since this OS code stored on the flash changes rarely, the wear of the flash is not as heavy as it were with random swap file data. ...
    (microsoft.public.windowsxp.hardware)
  • Re: Disk access is slowing my Eee PC
    ... because of something reading from or writing from the SSD, ... always happens when the disk activity indicator is lit and it stops ... through flash just like USB drives, adding "mapping layer" to simulate 512 byte sectors writes and to prevent flash wornout. ...
    (freebsd-questions)
  • Re: Removable Drive Letter Mapping
    ... You could try the script below. ... Modify Line 8 to reflect the number of flash disks you wish to monitor. ... Connect one of your USB drives and watch what happens. ...
    (microsoft.public.windowsxp.general)
  • Re: Removable Drive Letter Mapping
    ... Modify Line 8 to reflect the number of flash disks you wish to ... Modify Line 11 to reflect your first USB disk. ... Modify / insert extra lines for your remaining disks. ... Connect one of your USB drives and watch what happens. ...
    (microsoft.public.windowsxp.general)
  • Re: Help with a Mac Plus
    ... >> write such disks of course). ... > This trick will only work on the Apple floppy drives. ... I *think* that's only because the new USB drives don't work ... The sellotape trick above worked in the old days on various computers: ...
    (comp.sys.mac.system)