Tinywoods Posted October 30, 2005 Share Posted October 30, 2005 (edited) Id like to make a following script that can execute a program (ex. Start.exe) in a CD-ROM. I tried many scripts that I made, but those scripts did not work. Is there anyone who can help me? 1. I have 3 CD-Drives and more than 5 virtual CD-Drives. 2. Virtual CD-Drive letters are not fixed. So I may need to use DriveGetDrive 3. In my drives (HDD&CD-Drives), there are some exe-files which are the same name (ex. Start.exe) that I want to execute from the CD-ROM. So, I dont want to use FileFind* or something like that. 4. When I execute the program in the CDROM, I have to set the CDROM only; I can not set other CDROMs in CD-Drives. I want to have a caution message, when I set more than 2 CDROMs in CD-Drives. So I may have to use DriveStatus. 5. I'd like to put the script on my desktop. Edited November 2, 2005 by Tinywoods Link to comment Share on other sites More sharing options...
Confuzzled Posted October 30, 2005 Share Posted October 30, 2005 I'd like to make a following script that can execute a program (ex. Start.exe) in a CD-ROM. I tried many scripts that I made, but those scripts did not work. Is there anyone who can help me? 1. I have 3 CD-Drives and more than 5 virtual CD-Drives. 2. Virtual CD-Drive letters are not fixed. So I may need to use "DriveGetDrive"3. In my drives (HDD&CD-Drives), there are some exe-files which are the same name (ex. Start.exe) that I want to execute from the CD-ROM. So, I don't want to use "FileFind*" or something like that.4. When I execute the program in the CDROM, I have to set the CDROM only; I can not set other CDROMs in CD-Drives.I want to have a caution message, when I set more than 2 CDROMs in CD-Drives. So I may have to use "DriveStatus".5. I'd like to put the script on my desktop. Just put your program on the desktop. The command for the desktop location (see the Help file) is @DesktopCommonDir for all users, or @DesktopDir for the current user.You have a varying number of optical drives and the drive letter names are unpredictable. You cannot identify them by a common file name on a fixed location on the optical disc as the same file name is used for different things. I think you have a slight problem!Maybe you could find and extract the file metadetails such as version number, filesize, etc and uniquely identify them that way - the code snippets are here in the forums - do a search for them. Alternatively look for things that are different rather than the same on each mounted CDROM disc and work backwards from there.Have you checked out the autorun command for when CD volumes are mounted? It is extensively documented at the Micro$oft site.Good luck! Link to comment Share on other sites More sharing options...
Tinywoods Posted October 31, 2005 Author Share Posted October 31, 2005 (edited) Just put your program on the desktop. The command for the desktop location (see the Help file) is @DesktopCommonDir for all users, or @DesktopDir for the current user.You have a varying number of optical drives and the drive letter names are unpredictable. You cannot identify them by a common file name on a fixed location on the optical disc as the same file name is used for different things. I think you have a slight problem!Maybe you could find and extract the file metadetails such as version number, filesize, etc and uniquely identify them that way - the code snippets are here in the forums - do a search for them. Alternatively look for things that are different rather than the same on each mounted CDROM disc and work backwards from there.Have you checked out the autorun command for when CD volumes are mounted? It is extensively documented at the Micro$oft site.Good luck!Thank you for your interest in my thread. Basically, I have the exact same exe-files in different drives. So, the file version, file sizes are always same.In details, I intend to execute WPI.hta for Apps installing. Pls refer the site if you don't mind. http://www.wpiw.net/I have 4 WPI ISO images, and I intend to perform semi-automatic installing for my 4 machines via network. It should not an autorun DVD. I have to put only one DVD (or ISO image) in my drive when I perform semi-auto install. If I set more than 2 DVDs(or images), I always get in trouble. Therefore, I want to have a caution (Messages) when I make a mistake. and difine the DVD which I want to excute. Edited October 31, 2005 by Tinywoods Link to comment Share on other sites More sharing options...
Tinywoods Posted November 2, 2005 Author Share Posted November 2, 2005 Is there any idea? Link to comment Share on other sites More sharing options...
blademonkey Posted November 2, 2005 Share Posted November 2, 2005 Is there any idea? Well what about looking for a specific Volume Label (CD Label) across all your drive and running the EXE for that specific label? ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
Tinywoods Posted November 2, 2005 Author Share Posted November 2, 2005 Yes, it is one of solutions, but the CDROM-drive label is not fixed. Link to comment Share on other sites More sharing options...
blademonkey Posted November 2, 2005 Share Posted November 2, 2005 Yes, it is one of solutions, but the CDROM-drive label is not fixed.I'm not talking about the CDROM drive, im talking about the actual CD. Everytime you burn a CD it has to have a label. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
MHz Posted November 3, 2005 Share Posted November 3, 2005 I have some drive functions posted here in scripts'n'scraps. They work by label or filename recognition. Link to comment Share on other sites More sharing options...
Tinywoods Posted November 3, 2005 Author Share Posted November 3, 2005 @blademonkey Sorry, I misunderstood. @MHz Thank you. It works. Then I need to add a script to check numbers of CD. expandcollapse popup; Example use ; e.g. _FindCD('Setup.exe', 0) or _FindCD('CD Title', 1) ; $option: 0 = Filename in CD Root; ; $option: 1 = CD title $file = "\WPI\WPI.hta" $result = _FindCD($file, 0) MsgBox(0, "", $result) Func _FindCD($name, $option) Local $allocated, $drives While Not $allocated $drives = DriveGetDrive('CDROM') If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & '\') = 'READY' Then If $option = 0 Then If FileExists($drives[$i] & '\' & $name) Then $allocated = $drives[$i] Return $allocated EndIf ElseIf $option = 1 Then $allocated = $drives[$i] If DriveGetLabel($allocated) = $name Then Return $allocated EndIf EndIf EndIf Next If Not $allocated Then If MsgBox(5 + 16, 'Warning', 'Please insert CD into a drive now') = 2 Then Sleep(1000) If MsgBox(4 + 32, 'Important', 'Are you sure that you want to exit') = 6 Then Exit EndIf Sleep(2000) EndIf EndIf WEnd EndFunc $target = $result & $file MsgBox(0, "", $target) FileCreateShortcut ( $target, "C:\WPI\WPIHTA.lnk") run(@comspec & " /c start C:\WPI\WPIHTA.lnk") Link to comment Share on other sites More sharing options...
Tinywoods Posted November 4, 2005 Author Share Posted November 4, 2005 Another problem has happen. I made a script that is able to check how many "WPI.hta" files in drives. I tried to combine my script with MHz's script. Each file works alone but it dosen't work when combine into one script. Code A MHz's script expandcollapse popup; Example use ; e.g. _FindCD('Setup.exe', 0) or _FindCD('CD Title', 1) ; $option: 0 = Filename in CD Root; ; $option: 1 = CD title $file = "\WPI\WPI.hta" $result = _FindCD($file, 0) MsgBox(0, "Drive", $result) Func _FindCD($name, $option) Local $allocated, $drives While Not $allocated $drives = DriveGetDrive('CDROM') If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & '\') = 'READY' Then If $option = 0 Then If FileExists($drives[$i] & '\' & $name) Then $allocated = $drives[$i] Return $allocated EndIf ElseIf $option = 1 Then $allocated = $drives[$i] If DriveGetLabel($allocated) = $name Then Return $allocated EndIf EndIf EndIf Next If Not $allocated Then If MsgBox(5 + 16, 'Warning', 'Please insert CD into a drive now') = 2 Then Sleep(1000) If MsgBox(4 + 32, 'Important', 'Are you sure that you want to exit') = 6 Then Exit EndIf Sleep(2000) EndIf EndIf WEnd EndFunc $target = $result & $file MsgBox(0, "Path", $target) Code B My script (Check number of the files); Check the file if there is one or more than one files $search = FileExists($target) $count = 0 ; Check if the search was successful If $search = 0 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While $count = 0 $search = 1 $count = $count + 1 If $count >= 2 Then $cancel = MsgBox(4096, "Warning", "There are " & $Count & "files in DVDs. Check your DVD-Drives.") If $cancel = 1 Then EXIT EndIf Wend Code C (Execute "WPI.hta") It should be set at the end of combined script; Execute WPI.hta If $count = 1 Then FileCreateShortcut ( $target, "C:\WPI\WPIHTA.lnk", 1) Run(@comspec & " /c start C:\WPI\WPIHTA.lnk") EndIf Do you have any idea to combine above 3 scrips? Link to comment Share on other sites More sharing options...
MHz Posted November 5, 2005 Share Posted November 5, 2005 I am not sure of understanding your Code B script. You have mentioned multiple WPIs on multiple cdroms so I modified the function to return an array of matched drive letters if the optional parameter is used. expandcollapse popup; Example use ; e.g. _FindCD('Setup.exe', 0, 1);Find all setup.exe in all cdroms and return an array of matches ; _FindCD('Setup.exe') ;Find 1st instance of Setup.exe in a cdrom ; _FindCD('CD Title', 1) ;Find cdrom title ; $option: 0 = Filename in CD Root (default) ; $array: 1 = Return array of matched drive letters. ; $option: 1 = CD title $file = '\WPI\WPI.hta' $result = _FindCD($file, 0, 1) For $i = 1 To $result[0] MsgBox(0, '', $result[$i]) Next Func _FindCD($name, $option = 0, $array = 0) Local $allocated, $drives While Not $allocated $drives = DriveGetDrive('CDROM') If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & '\') = 'READY' Then If $option = 0 Then If FileExists($drives[$i] & '\' & $name) Then If $array = 1 Then $allocated = $allocated & $drives[$i] & '|' ConsoleWrite($allocated & @LF) Else Return $allocated EndIf EndIf ElseIf $option = 1 Then $allocated = $drives[$i] If DriveGetLabel($allocated) = $name Then Return $allocated EndIf EndIf EndIf Next If $option = 0 And $array = 1 Then If StringRight($allocated, 1) = '|' Then $allocated = StringTrimRight($allocated, 1) EndIf If $allocated Then Return StringSplit($allocated, '|') EndIf If Not $allocated Then If MsgBox(5 + 16, 'Warning', 'Please insert CD into a drive now') = 2 Then Sleep(1000) If MsgBox(4 + 32, 'Important', 'Are you sure that you want to exit') = 6 Then Exit EndIf Sleep(2000) EndIf EndIf WEnd EndFunc Perhaps that maybe more suitable for your needs. Link to comment Share on other sites More sharing options...
Tinywoods Posted November 6, 2005 Author Share Posted November 6, 2005 Sorry, I'm not good at making script and writing English. I just want to add a script that can check whether plural WPI.ISO images (or DVDs) are setting or not . Because I have 5 different images (including DVD) for my PCs. Sometimes I've left images in CD drives by mistake. In this case, I fail in Apps installing via a WPI image. Link to comment Share on other sites More sharing options...
MHz Posted November 6, 2005 Share Posted November 6, 2005 (edited) Ok, I understand some more. The default FindCD function will find the 1st cdrom that matches. So you could use just the 1st drive for testing to make it easy for your self, else you would have to do file check by created time stamp possibly to resolve on which was your latest cd created or some other means. The latter function would return an array and if $result[0] is larger then 1 then you could use a messagebox as warning that more then one match exists, but to resume with the 1st match or to choose is by more code. Using the last function couild be like this for checking multiple drive and using the first if desired: If $result[0] > 1 Then If MsgBox(4, 'Warning', 'You have ' & _ $result[0] & ' WPIs in the cdroms' & _ @LF & 'Do you want to continue') = 7 Then Exit EndIf EndIf $result[1] = $the_first_match_found Then use your latter code to run WPI. Edited November 6, 2005 by MHz Link to comment Share on other sites More sharing options...
MHz Posted November 6, 2005 Share Posted November 6, 2005 (edited) Well, this is a rough non-gui solution perhaps: Global $cddrive = '' If $result[0] > 1 Then ;; Choose to continue If MsgBox(4, 'Warning', 'You have ' & _ $result[0] & ' WPIs in the cdroms' & _ @LF & 'Do you want to continue') = 7 Then Exit For $i = 1 To $result[0] ; ; Select from multiple drives If MsgBox(4, 'Select cdrom', $result[$i]) = 6 Then $cddrive = $result[$i] ExitLoop EndIf Next EndIf Else ;; If only 1 drive is found then assigned it a letter If $result[0] = 1 Then $cddrive = $result[1] EndIf ; If no match then Exit If $cddrive = '' Then Exit ; $cddrive stores your drive letter for useage $cddrive = $your_selection $cddrive will hold you selection. Edit: Updated code. Edited November 6, 2005 by MHz Link to comment Share on other sites More sharing options...
Tinywoods Posted November 6, 2005 Author Share Posted November 6, 2005 Thank you very much MHz.Your script works well ! My question is ;; Choose to continue If MsgBox(4, 'Warning', 'You have ' & _ $result[0] & ' WPIs in the cdroms' & _ @LF & 'Do you want to continue') = 7 Then Exit For $i = 1 To $result[0] ; ; Select from multiple drives If MsgBox(4, 'Select cdrom', $result[$i]) = 6 Then $cddrive = $result[$i] ExitLoop EndIfThough I click "continue", nothing has happen without exit. I can not reach "Select from multiple drives" part. Could you check this point again? I like your script and I really want to use it with my WPI images. Link to comment Share on other sites More sharing options...
MHz Posted November 6, 2005 Share Posted November 6, 2005 Sure I can help. Sorry, forgot to add an Else after the ExitGlobal $cddrive = '' If $result[0] > 1 Then ; Choose to continue If MsgBox(4+262144, 'Warning', 'You have ' & _ $result[0] & ' WPIs in the cdroms' & _ @LF & 'Do you want to continue') = 7 Then Exit Else For $i = 1 To $result[0] ; Select from multiple drives If MsgBox(4+262144, 'Select cdrom', $result[$i]) = 6 Then $cddrive = $result[$i] ExitLoop EndIf Next EndIf Else ; If only 1 drive is found then assigned it a letter If $result[0] = 1 Then $cddrive = $result[1] EndIf ; If no match then Exit If $cddrive = '' Then Exit ; $cddrive stores your drive letter for useage $cddrive = $your_selectionI prepopulated the arrays and seems ok now.Test arraysDim $result[3] $result[0] = 2 $result[1] = 'c:' $result[2] = 'd:' Link to comment Share on other sites More sharing options...
totoymola Posted November 7, 2005 Share Posted November 7, 2005 Wutsup MHz and Tinywoods!! Link to comment Share on other sites More sharing options...
Tinywoods Posted November 7, 2005 Author Share Posted November 7, 2005 Hello MHz, Thank you very much ! It works well. Perfect !! The final version for WPI is as follows, expandcollapse popup; Example use ; e.g. _FindCD('Setup.exe', 0, 1);Find all setup.exe in all cdroms and return an array of matches ; _FindCD('Setup.exe') ;Find 1st instance of Setup.exe in a cdrom ; _FindCD('CD Title', 1) ;Find cdrom title ; $option: 0 = Filename in CD Root (default) ; $array: 1 = Return array of matched drive letters. ; $option: 1 = CD title $file = '\WPI\WPI.hta' $result = _FindCD($file, 0, 1) For $i = 1 To $result[0] MsgBox(0, '', $result[$i]) Next Func _FindCD($name, $option = 0, $array = 0) Local $allocated, $drives While Not $allocated $drives = DriveGetDrive('CDROM') If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & '\') = 'READY' Then If $option = 0 Then If FileExists($drives[$i] & '\' & $name) Then If $array = 1 Then $allocated = $allocated & $drives[$i] & '|' ConsoleWrite($allocated & @LF) Else Return $allocated EndIf EndIf ElseIf $option = 1 Then $allocated = $drives[$i] If DriveGetLabel($allocated) = $name Then Return $allocated EndIf EndIf EndIf Next If $option = 0 And $array = 1 Then If StringRight($allocated, 1) = '|' Then $allocated = StringTrimRight($allocated, 1) EndIf If $allocated Then Return StringSplit($allocated, '|') EndIf If Not $allocated Then If MsgBox(5 + 16, 'Warning', 'Please insert CD into a drive now') = 2 Then Sleep(1000) If MsgBox(4 + 32, 'Important', 'Are you sure that you want to exit') = 6 Then Exit EndIf Sleep(2000) EndIf EndIf WEnd EndFunc Global $cddrive = '' If $result[0] > 1 Then ; Choose to continue If MsgBox(4+262144, 'Warning', 'You have ' & _ $result[0] & ' WPIs in the cdroms' & _ @LF & 'Do you want to continue') = 7 Then Exit Else For $i = 1 To $result[0] ; Select from multiple drives If MsgBox(4+262144, 'Select cdrom', $result[$i]) = 6 Then $cddrive = $result[$i] ExitLoop EndIf Next EndIf Else ; If only 1 drive is found then assigned it a letter If $result[0] = 1 Then $cddrive = $result[1] EndIf ; If no match then Exit If $cddrive = '' Then Exit ; $cddrive stores your drive letter for useage ; $cddrive = $your_selection; delete left(;) if you need ; Execute WPI.hta $target = $cddrive & $file MsgBox(0, '', $target) If Not FileExists("C:\WPI\") Then DirCreate("C:\WPI\") Sleep(2000) EndIf FileCreateShortcut($target, "C:\WPI\WPIHTA.lnk") Sleep(2000) Run(@comspec & " /c start C:\WPI\WPIHTA.lnk") I canceled "$your_selection " part. Why don't you post this scrip in the WPI forum? It very useful information for a guy who want to execute WPI.hta from DVD. Hi, totoymola ! I'm happy because I got great support from MHz. Is he your friend? I just started to use AUTOIT from B's record installation, as you may remember. But it's still difficult for me to make complicated scripts. Link to comment Share on other sites More sharing options...
MHz Posted November 8, 2005 Share Posted November 8, 2005 (edited) I canceled "$your_selection " part. Why don't you post this scrip in the WPI forum? It very useful information for a guy who want to execute WPI.hta from DVD.$your_selection was just for poor show for output of $cddrive.My code is freely available on request. Alot of people seem to have their own methods already for WPI.I removed ConsoleWrite($allocated & @LF) as that was left in from testing the function.I also removedFor $i = 1 To $result[0] MsgBox(0, '', $result[$i]) Nextas I do not see the point of having so many messageboxes. The other If block should be enough.The MsgBox(0, '', $target) near the end is your testing messagebox I would assume? I will let you decide on that.The paths to WPI folder are hardcoded. You could use the @HomeDrive macro?I grouped your code together at the top of the script for easier reading amd added Exit to simply display the end of script.expandcollapse popup; Example FindCD function use ; _FindCD('Setup.exe', 0, 1);Find all setup.exe in all cdroms and return an array of matches ; _FindCD('Setup.exe') ;Find 1st instance of Setup.exe in a cdrom ; _FindCD('CD Title', 1);Find cdrom title ; $option: 0 = Filename in CD Root (default) ; $array: 1 = Return array of matched drive letters. ; $option: 1 = CD title $file = '\WPI\WPI.hta' $result = _FindCD($file, 0, 1) $cddrive = '' If $result[0] > 1 Then ; Choose to continue If MsgBox(4 + 262144, 'Warning', 'You have ' & _ $result[0] & ' WPIs in the cdroms' & _ @LF & 'Do you want to continue') = 7 Then Exit Else For $i = 1 To $result[0] ; Select from multiple drives If MsgBox(4 + 262144, 'Select cdrom', $result[$i]) = 6 Then $cddrive = $result[$i] ExitLoop EndIf Next EndIf Else ; If only 1 drive is found then assigned it a letter If $result[0] = 1 Then $cddrive = $result[1] EndIf ; If no match then Exit If $cddrive = '' Then Exit ; $cddrive stores your drive letter for useage ; Execute WPI.hta $target = $cddrive & $file MsgBox(0, '', $target) If Not FileExists("C:\WPI\") Then DirCreate("C:\WPI\") Sleep(2000) EndIf FileCreateShortcut($target, "C:\WPI\WPIHTA.lnk") Sleep(2000) Run(@ComSpec & " /c start C:\WPI\WPIHTA.lnk") Exit Func _FindCD($name, $option = 0, $array = 0) Local $allocated, $drives While Not $allocated $drives = DriveGetDrive('CDROM') If Not @error Then For $i = 1 To $drives[0] If DriveStatus($drives[$i] & '\') = 'READY' Then If $option = 0 Then If FileExists($drives[$i] & '\' & $name) Then If $array = 1 Then $allocated = $allocated & $drives[$i] & '|' Else Return $allocated EndIf EndIf ElseIf $option = 1 Then $allocated = $drives[$i] If DriveGetLabel($allocated) = $name Then Return $allocated EndIf EndIf EndIf Next If $option = 0 And $array = 1 Then If StringRight($allocated, 1) = '|' Then $allocated = StringTrimRight($allocated, 1) EndIf If $allocated Then Return StringSplit($allocated, '|') EndIf If Not $allocated Then If MsgBox(5 + 16, 'Warning', 'Please insert CD into a drive now') = 2 Then Sleep(1000) If MsgBox(4 + 32, 'Important', 'Are you sure that you want to exit') = 6 Then Exit EndIf Sleep(2000) EndIf EndIf WEnd EndFuncHappy WPI.Hi, totoymola ! You do get around. Edit: Removed $your_selection line that was still in the code Edited November 8, 2005 by MHz Link to comment Share on other sites More sharing options...
Tinywoods Posted November 8, 2005 Author Share Posted November 8, 2005 Wonderful ! Thank you, I will use above script without any modification. 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