I was inspired by this thread: http://www.tek-tips.com/viewthread.cfm?qid=938880&page=1
When you run the program, it attempts to resolve the first USB/Network conflict by assigning the usb drive to B: and opening it. Probably requires Win 2000/XP and Admin rights. I've done limited testing and code commenting.
REQUIRED DISKPART AND DP1.TXT
; Script to workaround a Windows bug that causes usb drive letter assignments to conflict with network drives ; The file dp1.txt contains two lines: ; list volume ; exit ; DiskPart.exe can be downloaded from http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/diskpart-o.asp ; DiskPart documentation http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/diskpart.mspx ; ; Philip Gump - 17 Feb 2005 - AutoIt 3.1.0 Script ; #NoTrayIcon If DriveStatus("B:") <> "INVALID" Then Run("explorer b:") Exit EndIf FileChangeDir(@TempDir) Dim $diskPart = "DiskPart.exe" Dim $dpScriptOne = "dpScriptOne.txt" Dim $dpScriptTwo = "dpScriptTwo.txt" Dim $infoOutput = "DiskPartInfo.txt" FileInstall("C:\DISKPART.EXE", $diskPart) FileInstall("C:\dp1.txt", $dpScriptOne) ; Otherwise, need to do magic If @OSType <> "WIN32_NT" Then MsgBox(4096,"Error", "This program does not run on " & @OSVersion) EndIf If IsAdmin() Then MsgBox(4096,"USB Drive maybe not ready yet...", "If device is plugged and Windows says it's ready, click OK.") Else MsgBox(4096,"Error", "You do not have access to change drive letters. Click OK to exit") Exit EndIf SplashTextOn("Please wait...", @CRLF & @CRLF & "Assigning the usb drive to letter B:") Dim $info = "" $run = RunWait(@Comspec & " /c " & $diskPart & " /s " & $dpScriptOne & " > " & $infoOutput, "", @SW_HIDE) $info = FileRead($infoOutput, FileGetSize($infoOutput)) SplashOff() $InfoWithHeaderRemoved = StringTrimLeft($info, StringInStr($info, "Volume 0")-1) $info = StringSplit($InfoWithHeaderRemoved, @CRLF) ;Sample element in the $info array looks like: ; "Volume 2 C HARD DRIVE NTFS Partition 73 GB Healthy System" For $i = 1 to $info[0] If StringStripWS($info[$i], 8) = "" Then ExitLoop ;quit when hit blank lines If StringInStr($info[$i], "Removeable") Then $letter = StringMid($info[$i],16,1) $volume = StringMid($info[$i],10,1) If DriveMapGet($letter) <> "" Or Not StringInStr($info[$i],"0 B") Then ; if drive letter is mapped to something else and Size is larger than 0 bytes, then $handle = FileOpen($dpScriptTwo, 2) If $handle <> -1 Then FileWrite($handle, "select volume " & $volume & @CRLF & "assign letter=B") FileClose($handle) EndIf RunWait($diskPart & " /s " & $dpScriptTwo, "", @SW_HIDE) Run("explorer b:") Exit EndIf EndIf Next MsgBox(4096,"Error", "USB drive not detected; no drive letter assignment made...")

Sign In
Register
Help

MultiQuote