Sign in to follow this  
Followers 0
Guest kumari

CDROM Help

6 posts in this topic

I need help with how to run a cd automatically if I do not know the CDdrive letter using AutoIt. Is there an environmental variable I can but in the RunOnce key at the registry?

:ph34r:

Thanks for your help!!!!!!

Share this post


Link to post
Share on other sites



DriveGet, OutputVar, List, CDROM

OutputVar - The name of the variable in which to store the result of Cmd.

Cmd, Value - See (only the List cmd ) below.

List [, Type]: Sets OutputVar to be a string of letters, one character for each drive letter in the system. If Type is omitted, all drive types are retrieved. Otherwise, Type should be one of the following words to retrieve only a specific type of drive: CDROM, REMOVABLE, FIXED, NETWORK, RAMDISK, UNKNOWN. If a problem is encountered OutputVar is made blank and ErrorLevel is set to 1.

AHK

DriveGetDrive ( "CDROM" )

Parameters typeType of drive to find:

"ALL", "CDROM", "REMOVABLE", "FIXED", "NETWORK", "RAMDISK", or "UNKNOWN"

Return Value Success:Returns an array of strings (drive letter followed by colon) of drives found. The zeroth array element contains the number of drives.Failure:Returns numeric 1 and sets @error to 1.

AU3

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I need help with how to run a cd automatically if I do not know the CDdrive letter using AutoIt.  Is there an environmental variable I can but in the RunOnce key at the registry?

:ph34r:

Thanks for your help!!!!!!

Unfortunately there is no built in function in AutoIt2 to detect a CD ROM - I think tehre are ways around it, but it's easiest to use AutoIt3's built in DriveGetDrive() function if you are able.

Here is a getcd.exe external util that may help (not tested) you should be able to call it from autoit2 : http://www.willowhayes.co.uk/download/getcd.exe

Edit: I can also knock up a compiled autoit3 script that sets an ENV variable if you like so you can call it easily from autoit2.

Edited by Jon

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here is an autoit2 script that calls a compiled autoit3 script in order to get the CDROM letter. A temporary file is used.

AutoIt2 Script

RunWait, au3getcd.exe
FileReadLine, CDROMLETTER, %TEMP%\\CDROMLETTER.txt, 1
MsgBox, 0, CD Letter is, %CDROMLETTER%

the au3getcd.exe file - (Compiled AutoIt3 script):

And if you are interested, here is the source file for the AutoIt3 script that was used to create au3getcd.exe:

Opt("ExpandEnvStrings", 1)

FileDelete("%TEMP%\CDROMLETTER.txt")

$letter = DriveGetDrive("CDROM")
If $letter[0] >= 1 Then
    FileWrite("%TEMP%\CDROMLETTER.txt", $letter[1])
Else
    FileWrite("%TEMP%\CDROMLETTER.txt", "")
EndIf

Edited by Jon

Share this post


Link to post
Share on other sites

Jon, thx for your/this excellent support.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0