myk3 Posted February 9, 2012 Share Posted February 9, 2012 My script requires the use of swapping out cds in the middle of the script. Everything works fine if i use a msgbox but i dont want the user to have to interact with the script if possible. My current script is this. This is a WinPE enviroment._EjectDisc() _Toast_Show(48,"Disc 2...","Please insert Disc 2") do do $DriveStatus = DriveStatus("Z:\") until $DriveStatus = "READY" if not FileExists ("Z:\test.txt") then _EjectDisc() until FileExists("Z:\test.txt") Func _EjectDisc() Local $sDrive, $aDrives, $oShell, $iTimer $aDrives = DriveGetDrive("all") If Not @error Then For $i = 1 To $aDrives[0] If DriveGetType($aDrives[$i] & "\") = "CDROM" Then $sDrive = StringUpper($aDrives[$i]) & "\" ExitLoop EndIf Next EndIf $oShell = ObjCreate("Shell.Application") $oShell.Namespace(17).ParseName($sDrive).InvokeVerb("Eject") $iTimer = TimerInit() While DriveStatus($sDrive) <> "NOTREADY" And TimerDiff($iTimer) < 10000 Sleep(10) WEnd EndFunc ;==>_EjectDiscEverything works well until the user puts in the wrong disc. When this happens it checks for the file and then if it is not the then it ejects the disc. The problem is i get the windows "No Disc" error similar to the one below.Is there some kind of blocking function that does not require the user to do anything similar to a msgbox? Again if the user puts the correct disc in I do not get the error only if they put in the wrong disc. Link to comment Share on other sites More sharing options...
Yashied Posted February 9, 2012 Share Posted February 9, 2012 (edited) Replace do do $DriveStatus = DriveStatus("Z:") until $DriveStatus = "READY" if not FileExists ("Z:test.txt") then _EjectDisc() until FileExists("Z:test.txt") to #Include <APIConstants.au3> #Include <WinAPIEx.au3> ... $Mode = _WinAPI_SetErrorMode($SEM_FAILCRITICALERRORS) While 1 If Not FileExists('Z:test.txt') Then Switch _WinAPI_GetLastError() Case 21 ; ERROR_NOT_READY ; Nothing Case Else _WinAPI_EjectMedia('Z:') EndSwitch Else ExitLoop EndIf Sleep(100) WEnd _WinAPI_SetErrorMode($Mode) Edited February 9, 2012 by Yashied meoit 1 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
myk3 Posted February 9, 2012 Author Share Posted February 9, 2012 Replace do do $DriveStatus = DriveStatus("Z:") until $DriveStatus = "READY" if not FileExists ("Z:test.txt") then _EjectDisc() until FileExists("Z:test.txt") to #Include <APIConstants.au3> #Include <WinAPIEx.au3> ... $Mode = _WinAPI_SetErrorMode($SEM_FAILCRITICALERRORS) While 1 If Not FileExists('Z:test.txt') Then Switch _WinAPI_GetLastError() Case 21 ; ERROR_NOT_READY ; Nothing Case Else _WinAPI_EjectMedia('Z:') EndSwitch Else ExitLoop EndIf Sleep(100) WEnd _WinAPI_SetErrorMode($Mode) worked great, thanks for the help 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