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@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: 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)
  • SUMMARY: storage array error notifications
    ... thanks to Tom Jones for sending me the script he uses to monitor ... I monitor my 3510s as part of my system monitoring scripts. ... Here's a portion from my script, using sccli commands: ... sccli> show disks ...
    (SunManagers)
  • Re: GEOM_FOX woes
    ... The setup ... >labels on the disks, according to the script in the announce message: ...
    (freebsd-current)
  • Re: Best place to spin down disk after boot?
    ... > Hi, I have a 5.1Release machine with currently four SCSI disks, out of ... Now I just wonder whether it would be more elegant to place a script ... # Script to spin down unneeded SCSI disks right after system start ...
    (freebsd-questions)
  • Re: Removable Drive Letter Mapping
    ... Modify Line 8 to reflect the number of flash disks you wish to monitor. ... Modify Line 11 to reflect your first USB disk. ... Connect one of your USB drives and watch what happens. ...
    (microsoft.public.windowsxp.general)