Jump to content
Sign in to follow this  

Auto-determine USB drive letter

Recommended Posts

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



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
    Return -1
EndFunc   ;==>_getScriptDriveType

So long,


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

@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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...