Jump to content
Sign in to follow this  
LowKey

Auto-determine USB drive letter

Recommended Posts

LowKey

I currently have a script that runs with autorun, that causes the drive's background picture and text colour to change using the Desktop.ini file, then opens the drive with run("explorer.exe e:"). I was wondering, first off, if and how can I automatically determine the drive letter? Secondly, is there a better/more efficient way to open the drive?


~T3CHM4G3~PROjECTS: Telnet Client

Share this post


Link to post
Share on other sites
Danny35d

$USB_Drive = StringLeft(@ScriptDir, 2)
Run(@ComSpec & ' /c Explorer ' & $USB_Drive, @ScriptDir, @SW_HIDE)


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

???

MsgBox(64, 'ScriptDrive', _getScriptDrive())
MsgBox(64, 'ScriptDrive mit "\"', _getScriptDrive(1))
MsgBox(64, 'ScriptDriveType ', _getScriptDriveType())

Func _getScriptDrive($iflag = 0)
    Local $drive = StringRegExp(@ScriptDir, '[a-zA-Z]\:', 1)
    If @error <> 0 Then Return -1
    If $iflag = 0 Then Return $drive[0]
    Return $drive[0] & '\'
EndFunc   ;==>_getScriptDrive

Func _getScriptDriveType()
    Local $drive = StringRegExp(@ScriptDir, '[a-zA-Z]\:', 1)
    If @error <> 0 Then Return -1
    Switch DriveGetType($drive[0])
        Case "Unknown"
            Return 1
        Case "Removable"
            Return 2
        Case "Fixed"
            Return 3
        Case "Network"
            Return 4
        Case "CDROM"
            Return 5
        Case "RAMDisk"
            Return 6
    EndSwitch
    Return -1
EndFunc   ;==>_getScriptDriveType

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
slayerz

@Low Key, from what I can understand is, you want your script to automatically determine the drive to open your USB drive rite?

I have a simple solution for this...

Well, I do write batch script like this :

START /max explorer.exe %removable%\

save it as anyname.bat, put it in your USB drive, it should automatically open your USB drive when executed

BTW, that's only my basic idea.You could write it in autoit using _rundos()

Edited by slayerz

AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×