Jump to content

CDROM Help


Guest kumari
 Share

Recommended Posts

Guest kumari

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!!!!!!

Link to comment
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
Link to comment
Share on other sites

  • Administrators

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
Link to comment
Share on other sites

  • Administrators

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
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...