Diana (Cda) Posted May 25, 2011 Posted May 25, 2011 (edited) I don't know what I did wrong but after searching forum and help file found DriveGetLabel. The script I made is showing up blank despite the fact that all my drives have labels. What did I do wrong here, pls?: ;================================================ $var = DriveGetLabel(@ScriptDir & "\") ;================================================ MsgBox(4096,"Volume Label: ","The drive label is: " & $var & " ") Further, it would be nice for the message box to have the output like this: D = UFD p.s., When I put the actual drive letter in ("D:" instead of "@ScriptDir & "\""), I got the desired output of "UFD" but I'd prefer to use @ScriptDir so that this one script works in any folder to know what the root volume drive letter and volume are. Thanks! Edited May 25, 2011 by Diana (Cda)
wakillon Posted May 25, 2011 Posted May 25, 2011 (edited) you must indicate Path of drive to receive information from. Like c:\ or D:\ .. you can see for _PathSplit function. Edited May 25, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
GEOSoft Posted May 25, 2011 Posted May 25, 2011 (edited) Then you should perhaps take a look at the requirements for DriveGetLabel() and the return of @ScriptDir. Try this instead $var = DriveGetLabel(StringLeft(@ScriptDir, 2)) EDIT" Also this one $var = DriveGetLabel(StringLeft(@ScriptFullPath, 2)) Edited May 25, 2011 by GEOSoft George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Diana (Cda) Posted May 25, 2011 Author Posted May 25, 2011 On 5/25/2011 at 3:25 PM, 'GEOSoft said: Then you should perhaps take a look at the requirements for DriveGetLabel() and the return of @ScriptDir. Try this instead $var = DriveGetLabel(StringLeft(@ScriptDir, 2)) EDIT" Also this one $var = DriveGetLabel(StringLeft(@ScriptFullPath, 2)) Oh, okay. I don't understand why what you did with DriveGetLabel works rather than just with the command but the good thing is that they both work! <vbg> Thanks. They don't give the drive letter but they give the volume name, which is great. I have 2 folders I open up with a script that are identical, just that one is on the hdd and the other on the usb stick. With the script the drive label will help me know at a glance which one I'm on. I prefer to work on the financials on the hdd and then copying them over to the usb stick rather than vice versa. Thanks. --------------------- p.s., to get the drive letter to also be displayed, what command would we use, pls? Is there anything? If there is a way, I'd then use this script: ;================================================ $var = DriveGetLabel(StringLeft(@ScriptDir, 2)) ;================================================ MsgBox(4096,"Volume Label: ","The drive is: " & @CRLF & @CRLF & [drive letter] & " = " & $var & " ") where [drive letter] would be where that AutoIt command would go. Just out of curiousity.
kaotkbliss Posted May 25, 2011 Posted May 25, 2011 $driveletter=StringLeft(@ScriptDir, 2) 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
GEOSoft Posted May 25, 2011 Posted May 25, 2011 (edited) Func _ExtractDriveFromPath($vPath) Return StringLeft($vPath, 2) EndFunc Unless of course you want me to get fancy and do it with StringRegExpReplace() and an extra parameter to include the back-slash (or not). Edited May 25, 2011 by GEOSoft George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
UEZ Posted May 25, 2011 Posted May 25, 2011 Here another method using WMI: expandcollapse popup;coded by UEZ 2011 #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_UseUpx=n #include <Array.au3> $oMyError = ObjEvent("AutoIt.Error", "oMyError") ; Install a custom error handler Global $ip = "localhost" If $CmdLine[0] > 0 Then $ip = $CmdLine[1] $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $ip & "\root\cimv2") $aMyDriveLabels = GetWMI($ip) _ArrayDisplay($aMyDriveLabels) Func GetWMI($srv) Local $DriveLabel, $sDriveLabels, $i Local $aDriveLabels[26][2] $colItems = $objWMIService.ExecQuery("SELECT Name, VolumeName FROM Win32_LogicalDisk", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems $aDriveLabels[$i][0] = $objItem.Name $aDriveLabels[$i][1] = $objItem.VolumeName $i += 1 Next EndIf ReDim $aDriveLabels[$i][2] Return $aDriveLabels EndFunc Func oMyError() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.Description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.WinDescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.Number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.LastDllError & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.Scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.Source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.Helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.HelpContext _ ) EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now