MHz Posted August 23, 2004 Share Posted August 23, 2004 I'm using Autoit for creating an unattended windows cd. The script in reference is the RunOnceEx script for program installations. Runs from harddrive to install from CD. I have this script looks for Win51 file on CD. (relevent part only) ----------------- ;~ Script Start $ZZZ = DriveStatus("CDROM") $TRAY = DriveGetDrive("CDROM") If FileExists($TRAY[1] & "\WIN51") Then $ROM = $TRAY[1] ElseIf FileExists($TRAY[2] & "\WIN51") Then $ROM = $TRAY[2] ElseIf FileExists($TRAY[3] & "\WIN51") Then $ROM = $TRAY[3] EndIf ;~ MsgBox(4096, "Drive", "Found " & $ROM & "\WIN51") RegWrite($KEY, "TITLE", "REG_SZ", "Installing Applications") RegWrite($KEY & "\001", "", "REG_SZ", "Preparing Installation...") RegWrite($KEY & "\001", "1", "REG_SZ", $ROM & "\Software\prepare.cmd") ;~ Script End --------------- This will work but I think a loop may be better. Does not check every CDRom available. If CD is missing then script will fail. Etc... Another script (relevent part only) looks for CD label. (Label chosen for ease) ----------------- ;~ Script Start $CDLABEL = "Windows" $X = DriveGetDrive("CDROM");Returns an array with all the CD-Rom's drive letters: $ANS = DriveGetLabel($X[1]) FindCD() MsgBox(0, "Information", "Installation will commence now") Func FindCD() If $ANS = $CDLABEL Then MsgBox(0, "Information", "CD label is " & $ANS & " in " & $X[1] & " drive") Else $Y = MsgBox(1, "Notice", "Please put correct CD in drive " & $X[1] & " then click ok") If $Y = 2 Then Exit Sleep(1000) FindCD() EndIf EndFunc ;==>FindCD RegWrite($KEY, "TITLE", "REG_SZ", "Installing Applications") RegWrite($KEY & "\001", "", "REG_SZ", "Preparing Installation...") RegWrite($KEY & "\001", "1", "REG_SZ", $ROM & "\Software\prepare.cmd") ;~ Script End --------------- Still has the faults of the 1st script. Does aleast do a error check on the first drive. Does anyone know of a foolproof script that may suit this task. There would surely be a script to CD rom tasks, such as this? Link to comment Share on other sites More sharing options...
this-is-me Posted August 23, 2004 Share Posted August 23, 2004 $drvs = DriveGetDrive("CDROM") If Not @error Then For $i = 1 To $drvs[0] If DriveStatus($drvs[$i] & "\") = "READY" Then If FileExists($drvs[$i] & "\WIN51") Then $cddrive = $drvs[$i] EndIf EndIf Next EndIf Who else would I be? Link to comment Share on other sites More sharing options...
MHz Posted August 23, 2004 Author Share Posted August 23, 2004 @ this-is-me Very good I added a little check with while...wend at the end to check incase the cd was not in the drive for some silly reason. Well, we all can make silly mistakes. :"> I think that you nailed it. Unless it is possible to insert the check within your if...endif block, so it is self contained? What is shown is foolproof. Which is what I wanted. Dim $CDDRIVE FindCD() Func FindCD() $DRVS = DriveGetDrive("CDROM") If Not @error Then For $I = 1 To $DRVS[0] If DriveStatus($DRVS[$I] & "\") = "READY" Then If FileExists($DRVS[$I] & "\WIN51") Then $CDDRIVE = $DRVS[$I] EndIf EndIf Next EndIf EndFunc ;==>FindCD While $cddrive = "" MsgBox(16, "Warning", "Please insert CD into drive now") Sleep(2000) FindCD() Wend MsgBox(0, "Installing programs", "Using drive " & $CDDRIVE) Thanks this-is-me You are cool Link to comment Share on other sites More sharing options...
this-is-me Posted August 23, 2004 Share Posted August 23, 2004 the READY status indicates that there is a cd in the drive and it can be read. Who else would I be? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now