Jump to content

DriveGetDrive doesn't work


Recommended Posts

Hi all,

I want to get the driveletter from the drive where the script is running from (an external Harddisk). So I tried the following:

$1 = DriveGetDrive("REMOVABLE")
MsgBox(64, "Drive", $1)oÝ÷ Ø­¶­v'gßÛp¢¹ºÜ"¶aÆ®¶­sbb33c³ÒG&fTvWDG&fRgV÷C¶ÆÂgV÷C²¤×6t&÷cBÂgV÷C´G&fRgV÷C²Âb33c³

I'm getting the same error. Whats wrong?

Link to comment
Share on other sites

Hi,

Maybe the OS does not recognize like a removable disk, but as a hard disk.

Double check!

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Since there is no @ScriptDrive macro, I use this function in many different scripts where I want the script to go to the @ScriptDir drive for something not actually in @ScriptDir:

$ScriptRoot = _ScriptRoot()
MsgBox(64, "Script Root", "Script root is: " $ScriptRoot)

;--------------------------------------
; Function _ScriptRoot()
;   Return the root of @Script dir, either drive or CIFS share path
;   Call with _ScriptRoot()
;   On success returns the root of @ScriptDir without trailing backslash
;       (i.e. "D:", or "\\ServerName\Share"
;   On failure returns 0 and sets @error
;--------------------------------------
Func _ScriptRoot()
    ; Find the script root
    Local $sScriptRoot
    Select
        Case StringMid(@ScriptDir, 2, 1) = ':'
            $sScriptRoot = StringLeft(@ScriptDir, 2)
        Case StringLeft(@ScriptDir, 2) = '\\'
            $sScriptRoot = StringReplace(@ScriptDir, '\\', '')
            Local $avScriptRoot = StringSplit($sScriptRoot, '\')
            $sScriptRoot = '\\' & $avScriptRoot[1] & '\' & $avScriptRoot[2]
        Case Else
            ; Case not handled: @ScriptDir does not start with "\\" or a drive letter.
            Return SetError(1, 0, 0)
    EndSelect
    
    ; Test the derived script root
    If FileExists($sScriptRoot & "\") Then
        Return $sScriptRoot
    Else
        ; Derived script root does not exist
        Return SetError(2, 0, 0)
    EndIf
EndFunc   ;==>_ScriptRoot

:shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...