Chimaera Posted June 9, 2013 Share Posted June 9, 2013 I have a function that tests an archive before extraction. The test works fine except when the archive is passworded The return codes don't exist for password needed, and plus it just sits there waiting for it to be inputted. This is the offending section I have been testing all the codes to see if any trigger on passwords but they dont So can the cmd window be read? specifically the bit "Enter password <will not be echoed>" Also the window will normally be hidden with @SW_HIDE so can it still be read then? This is about the only way i can think of to determine that it hangs on a password unless someone has a better idea? Btw the password will probably not be available to me so i only need it to throw an error if its passworded If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted June 9, 2013 Share Posted June 9, 2013 Hi, Take a look at the StdoutRead function. Br, FireFox. Link to comment Share on other sites More sharing options...
water Posted June 9, 2013 Share Posted June 9, 2013 To extend the reply of FireFox a bit: Replace RunWait with Run and set the flags to "BitOr($STDIN_CHILD, $STDOUT_CHILD). Then use StdOutRead until you get the "Enter password" line. Then pass the password using StdInWrite. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Chimaera Posted June 9, 2013 Author Share Posted June 9, 2013 I actually dont need the password at all All i need to do is detect this text in the window "Enter password <will not be echoed>" and force an exit of the program with an error message Func _Archive_Test() $aRarFile = _RecFileListToArray(@ScriptDir, "*.7z;*.001", 1, 0) ;~ _ArrayDisplay($aRarFile, ".Rar Files") If IsArray($aRarFile) Then For $i = 1 To $aRarFile[0] $test = Run(@ComSpec & ' /c ' & @TempDir & '\Sup\7z.exe' & ' t ' & '"' & $aRarFile[$i] & '"', "", @SW_SHOW,BitOr($STDIN_CHILD, $STDOUT_CHILD)) MsgBox(64, "Rar Test", "Test = " & $test & " - " & "Error = " & @error) If $test = 2 Then MsgBox(64, "Archive Failure", "Archive Extraction Failed, Manual Intervention Needed") Exit EndIf While 1 Local $sOutput = StdoutRead($test) If @error Then MsgBox(64, "StdRead Error", "Text not available") ExitLoop EndIf WEnd Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@LF)), @LF) If @error Then MsgBox(4096, "", "It appears there was an error trying to find all the files in the current script directory.") Else $array = _ArrayDisplay($aArray) EndIf ;~ ElseIf $test = 1073741510 Then ;~ MsgBox(64, "Archive Failure 1 ", "Archive Extraction Failed, Possible Password") ;~ ElseIf $test = 7 Then ;~ MsgBox(64, "Archive Failure 7 ", "Archive Extraction Failed, Possible Password") Next EndIf Sleep(200) EndFunc ;==>_Archive_Test() Ive got this so far but the cmd window is black with no text on it so i must have done something wrong Ill try again tommoz If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Mat Posted June 9, 2013 Share Posted June 9, 2013 It will be black, because stdout and stdin have been redirected to your program by the flags. Just use @SW_HIDE instead of @SW_SHOW so no cmd window will be shown at all. You also need to test within the loop. Here is an example using pause: #include <Constants.au3> Local $iPid = Run("cmd /c pause", @ScriptDir, @SW_HIDE, BitOR($STDIN_CHILD, $STDOUT_CHILD)) ProcessWait($iPid) Local $sOutput = "" While 1 $sOutput = StdoutRead($iPid) If @error Then ExitLoop If MsgBox($MB_YESNO, Default, '"' & $sOutput & '"') = $IDYES Then StdinWrite($iPid, @LF) EndIf WEnd AutoIt Project Listing Link to comment Share on other sites More sharing options...
Chimaera Posted June 10, 2013 Author Share Posted June 10, 2013 Thx Guys Doesn't seem that hard from your eg, i must admit the one in the helpfile is a bit Ott Ive adapted yours into mine and it just hangs on the extraction task until i end it in task manager Then i get the error message "Text not available" Func _Archive_Test() $aRarFile = _RecFileListToArray(@ScriptDir, "*.7z;*.001", 1, 0) ;~ _ArrayDisplay($aRarFile, ".Rar Files") If IsArray($aRarFile) Then For $i = 1 To $aRarFile[0] $ArchiveTest = Run(@ComSpec & ' /c ' & @TempDir & '\Sup\7z.exe' & ' t ' & '"' & $aRarFile[$i] & '"', "", @SW_HIDE, BitOR($STDIN_CHILD, $STDOUT_CHILD)) ;~ MsgBox(64, "Rar Test", "Test = " & $ArchiveTest & " - " & "Error = " & @error) ProcessWait($ArchiveTest) $sOutput = "" While 1 $sOutput = StdoutRead($ArchiveTest) If @error Then MsgBox(64, "StdRead Error", "Text not available") ExitLoop EndIf WEnd If MsgBox($MB_YESNO, Default, '"' & $sOutput & '"') = $IDYES Then StdinWrite($sOutput, @LF) EndIf ;~ $aArray = MsgBox(64, "write test", StdinWrite($sOutput, @LF)) ;~ If @error Then ;~ MsgBox(4096, "", "Error = " & @error) ;~ EndIf Next EndIf Sleep(200) EndFunc ;==>_Archive_Test Ive tried to slim out the rubbish but it still isnt working like yours Ill keep trying If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
water Posted June 10, 2013 Share Posted June 10, 2013 @error is set when EOF is reached (no more messages to read) and when a "real" error occurres. Can you post the value of @error? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Chimaera Posted June 10, 2013 Author Share Posted June 10, 2013 0 according to the run i just did so did it not read the file or did it not get to the end? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted June 10, 2013 Share Posted June 10, 2013 If you know the extraction ending text then wait for it and exit the loop. Link to comment Share on other sites More sharing options...
Chimaera Posted June 10, 2013 Author Share Posted June 10, 2013 Yes i do m8 its this "Enter password <will not be echoed>" Just to clarify im just trying to read the text to find the text above the cmd window halts on that text Which i can then use to exit the script and notify the user he needs to sort out his files manually because they have a password set on them Its basically an error check to see if a password exists thats all If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Solution FireFox Posted June 10, 2013 Solution Share Posted June 10, 2013 I don't really understand what's the problem $sOutput = StdoutRead($ArchiveTest) If @error Or StringInStr($sOutput, "Enter password", 2) > 0 Then ExitLoop Link to comment Share on other sites More sharing options...
Chimaera Posted June 10, 2013 Author Share Posted June 10, 2013 Using FireFox excellent suggestion i ended up with this ProcessWait($ArchiveTest) $sOutput = "" While 1 $sOutput = StdoutRead($ArchiveTest) If StringInStr($sOutput, "Enter password", 2) > 0 Then MsgBox(64, "Password Error", "Archive Is Passworded") Exit ElseIf StringInStr($sOutput, "Error:", 2) > 0 Then MsgBox(64, "Archive Error", "Archive Extraction Failed") Exit EndIf WEnd Many thanks guys If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted June 10, 2013 Share Posted June 10, 2013 ah I'm glad you got it working 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