Jump to content
Sign in to follow this  

DriveGetLabel not giving the expected result?

Recommended Posts

Says this in the helpfile

Returns Volume Label of a drive

Now the volume label i would find if i use in a cmd window with this

vol c:

gives this E649-2540 which is completly different to the DriveGetLabel result

what is the easiest way to do the vol c: within autoit or do i need to do some kind of cmd output to achieve the same result as vol c:

mine will be @scriptdir i guess as im querying the vol label of a pendrive and if it matches then it allows the gui to run to restrict the software to a set of usb pendrives and hard drives only

Any suggestions?

Share this post

Link to post
Share on other sites

You're confusing Volume Label (the name of the drive) with the Volume Serial Number. The E649-2540 is the serial number of the drive's volume, a made up number that's created when the drive is formatted. You need the DriveGetSerial if you're looking for the serial number

ConsoleWrite(DriveGetLabel("C:") & @TAB & Hex(DriveGetSerial ( "c:" )) & @CRLF)

Note the Hex function included in there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post

Link to post
Share on other sites

Hmm ok that works the problem im going to have is resolving it to a usb pendrive

I have a list of about 10 drives 2 internal hard drives 7 usb drives and 1 network drive

The hdrives and network have paths so i can c: etc 

How do i get at the serial of a usb when the file is on the usb?

@scriptdir returns 00000000

@scriptdir works when the file is on the root but returns zero when its one level down in a folder sad.png

This seems to work

reduce the path no matter where it is

ConsoleWrite( Hex(DriveGetSerial ( StringLeft(@ScriptDir,2) )) & @CRLF)

or more likely for me

Local $SerialTest = Hex(DriveGetSerial ( StringLeft(@ScriptDir,2) ))
ConsoleWrite( $SerialTest & @CRLF)
Edited by Chimaera

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  

  • Create New...