Sign in to follow this  
Followers 0
roberts

Detecting a Blank CD vs an Empty Drive

5 posts in this topic

Is there any way to differentiate a CD drive that is empty from one that contains a blank CD? (My specific problem is that I want the operator told to insert a blank disk if none is present so that an overnight backup can be performed.)

The following functions do NOT make a distinction between the two:

DriveStatus()

DriveSpaceTotal()

DriveSpaceFree()

DriveGetFileSystem()

All of these return the same values for empty drives as for ones containing a blank CD.

I have not been able to find even a general answer to this on the internet. I suspect that this problem is in CD hardware generally since so many have been complaining that their CD drive/burning software cannot recognize a blank CD/DVD.

Thanks in advance for any help.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Is there any way to differentiate a CD drive that is empty from one that contains a blank CD? (My specific problem is that I want the operator told to insert a blank disk if none is present so that an overnight backup can be performed.)

The following functions do NOT make a distinction between the two:

DriveStatus()

DriveSpaceTotal()

DriveSpaceFree()

DriveGetFileSystem()

All of these return the same values for empty drives as for ones containing a blank CD.

I have not been able to find even a general answer to this on the internet. I suspect that this problem is in CD hardware generally since so many have been complaining that their CD drive/burning software cannot recognize a blank CD/DVD.

Thanks in advance for any help.

FROM THE HELP PAGE:

DriveStatus

--------------------------------------------------------------------------------

Returns the status of the drive as a string.

DriveStatus ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Value Interpretation

UNKNOWN Drive may be unformatted (RAW).

READY Typical of hard drives and drives that contain removable media.

NOTREADY Typical of floppy and CD drives that do not contain media.

INVALID May indicate the drive letter does not exist or that a mapped network drive is inaccessible.

PAY ATTENTION to the bolded part :D Btw, it worked like a charm for my DVDRW's who havn't been formatted (which returns an UNKNOWN status because the FileSystem is RAW). So it really should work for you. If not, give us an example of the code your trying to use.

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites

Here is one solution:

$sCDROM = "H:\"

If _CDROMIsBlank($sCDROM) Then
    $iAsk = MsgBox(36, "CD " & $sCDROM & " is Blank!", "Now we will burn to this CD something :) ... OK?")
    
    If $iAsk <> 6 Then Exit
ElseIf @error Then ;CDROM is "NOTREADY"
    MsgBox(48, "CD " & $sCDROM & " is NOT Ready!", "Oops, please insert a CD (a Blank one please :) )")
    CDTray($sCDROM, "Open")
Else
    MsgBox(48, "CD " & $sCDROM & " is NOT Blank!", "Oops, please insert a *Blank* CD!")
    CDTray($sCDROM, "Open")
EndIf

Func _CDROMIsBlank($sCDROM)
    If DriveStatus($sCDROM) = "NOTREADY" Then Return SetError(1, 0, 0)
    
    Return DriveSpaceFree($sCDROM) = DriveSpaceTotal($sCDROM)
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

The following code produces the same message for an empty CD drive and for one containing

a blank disk. Note that in these two cases, it displays a diagnostic string ($DriveInfo) that is identical.

(Why are all of my tabs being removed?! Please forgive the unnecessarily difficult format.)

-----CDCHECK.AU3

; CdCheck: checks status of CDROM burner. This version compiled for Win2K.

;

; R Supansic 04.19.2008

;

; Command line parameter 1: Full path to file for testing for backup CD.

#include "GUIConstantsEX.au3"

#include "Date.au3"

$CDDrives = DriveGetDrive( "CDROM" )

If ( $CDDrives[ 0 ] = 0 ) Then

MsgBox( 4096, "", "No CD drive was found on this computer." )

Exit

EndIf

$DriveLetter = $CDDrives[ 1 ]

$TestFile = $CmdLine[ 1 ]

CDTray( $DriveLetter, "open" ) ; Force initialization of drive

CDTray( $DriveLetter, "closed" )

$BlankState = "NOTREADY" ; No CD/Blank CD status for Win2K

;$BlankState = "UNKNOWN" ; No CD/Blank CD status for Win9x

$DriveState = DriveStatus( $DriveLetter )

Switch $DriveState

Case "INVALID"

MsgBox( 4096, $DriveState, "The CD drive letter is not valid." )

Case $BlankState

$DriveSize = DriveSpaceTotal( $DriveLetter )

$DRiveFree = DriveSpaceFree( $DRiveLetter )

$FSType = DriveGetFileSystem( $DriveLetter )

If ( $FSType = 1 ) Then

$FSstr = "BLANK"

Else

$FSstr = $FSType

EndIf

$DriveInfo = String( $DriveSize ) & "|" & String( $DriveFree ) & "|" & $FSType & "|"

$DriveInfo = $DriveInfo & $FSstr & "|" & String( @error ) & "|"

If @error = 1 Then

MsgBox( 4096, $DriveState, $DriveInfo & " Please place a blank disk in the CD drive." )

Else

MsgBox( 4096, $DriveState, $DriveInfo & " There is a blank disk in the drive." )

EndIf

Case "READY"

If FileExists( $TestFile ) Then

MsgBox( 4096, $DriveState, "There is a backup disk in the CD drive." )

Else

MsgBox( 4096, $DriveState, "There is a non-backup disk in the CD drive." )

Endif

EndSwitch

Exit

Share this post


Link to post
Share on other sites

(Why are all of my tabs being removed?! Please forgive the unnecessarily difficult format.)

Try warpping your code in code tags. like [ code ] and [ /code ] Note no spaces between the brackets. And then your code will be tabbed and much easier to read. Still looking at the script.

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

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  
Followers 0