Source language: Translate to:

CDROM label

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

CDROM label

Postby Carl_SA » Mon Nov 20, 2006 2:21 am

I would like to us the CDROM label as a validation for an application to startup. Do you know of a way for me to read the CDROM label into a variable?
Posts: 91
Joined: Sat Dec 17, 2005 12:47 am

Postby Sam Cox » Mon Nov 20, 2006 4:52 am

From a batch file, the old DOS "VOL" command can do the job.
Displays the disk volume label and serial number, if they exist.
VOL [drive:]

For example:
Volume in drive C is XYZZY
Volume Serial Number is 4845-2EB9

Here is a code snippet (untested) that should work for you:
Code: Select all
.name of temporary batch file
SetVar "[batch]" "[tempdir]temp.bat"

.name of temporary result file
SetVar "[result]" "[tempdir]temp.txt"

.construct batch file to execute VOL command
FileWrite "[batch]" "all" "vol [CDRomDrive] >[result]"

.execute batch file
Run "[batch]" "" "RunOnce+Wait+Hidden" "" ""

.read first line of result file
FileRead "[result]" "1" "[line]"

.parse the line
StrParse "[line]" "[#32]" "[word]" "[wordcount]"

.select the CDROM label
SetVar "[CDRomLabel]" "[word[wordcount]]"

.erase batch and result files (optional)
FileErase "[batch]"
FileErase "[result]"
User avatar
Sam Cox
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests