Jump to content
Sign in to follow this  
fiodal

Cd Rom

Recommended Posts

fiodal

Can someone help me please...

What is the code to check if the CD ROM exists. And if it does, return the value or drive letter?

Thanks..

Share this post


Link to post
Share on other sites
Nutster

Try:

$x = DriveGetType("CDROM") ;Returns an array with all the CD-Rom's drive letters:

if $x[0] >0 Then
     $cdrom = $x[1]
else
     $cdrom = "" ;None found
endif

msgbox(0,"Insert Disk", "Please put the CD-Rom in drive " & $cdrom)

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites
fiodal

Your a great help

Thank you Nutster

Share this post


Link to post
Share on other sites
fiodal

Nutster get an array error..

Where and how do I declare the array?

if $x[0] >0 Then

if $x^ERROR

Error: Subscript used with non-Array variable.

Share this post


Link to post
Share on other sites
scriptkitty

Yea, that isn't the right usage, it doesn't return an array:

DriveGetType

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

Returns drive type.

DriveGetType ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: Returns the type of drive: "Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk"

Failure: Returns numeric 1 and sets @error to 1.

so usage would be DriveGetType ( "c:\" )

you can do DriveGetDrive ( "CDROM" ) like:

$var = DriveGetDrive( "CDROM" )
If NOT @error Then
    MsgBox(4096,"", "Found " & $var[0] & " drives")
    For $i = 1 to $var[0]
        MsgBox(4096,"Drive " & $i, $var[$i])
    Next
EndIf

just off by a few letters there

or:

$x = DriveGetDrive("CDROM");Returns an array with all the CD-Rom's drive letters:

if $x[0] >0 Then
    $cdrom = $x[1]
else
    $cdrom = "";None found
endif

msgbox(0,"Insert Disk", "Please put the CD-Rom in drive " & $cdrom)
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites
herworth

I'm a very simple guy and I use this function

#include - once
local $CDDrive
Func FindCD()
$CDDrive = ""
for $x = 68 to 71
if fileexists(Chr($x) & ":\") then
$CDDrive = Chr($x) & ":\"
exitloop
endif
next
Return $CDDrive
EndFunc

It works fine every time for me.


[u][font="Arial"]Pete[/font][/u]

Share this post


Link to post
Share on other sites
Valik

One note, declaring something as Local outside the scope of a function doesn't make it local to the function, it makes it global (Local to global scope is still global to everything else is one way to rationalize that out).

Share this post


Link to post
Share on other sites
Nutster

Yea, that isn't the right usage, it doesn't return an array:

just off by a few letters there

or:

$x = DriveGetDrive("CDROM");Returns an array with all the CD-Rom's drive letters:

if $x[0] >0 Then
    $cdrom = $x[1]
else
    $cdrom = "";None found
endif

msgbox(0,"Insert Disk", "Please put the CD-Rom in drive " & $cdrom)
Oops, wrong function. Sorry. Yeah I meant DriveGetDrive, not DriveGetType.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.