Docfxit Posted October 29, 2017 Posted October 29, 2017 (edited) I would like to read the text in a CMD window and process some commands depending on what it finds. Currently it isn't finding the $PID because the run cmd starts a program and the program starts the CMD window. Run($DestPath & "\Client\UpdateInstaller.exe") WinWaitActive("WSUS Offline Update 11.0.3 - Installer") ControlClick("WSUS Offline Update 11.0.3 - Installer", "Start", "Button16", "left", 1, 50, 15) Sleep(100) ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:ConsoleWindowClass]", "", 10) ; Retrieve the PID of Notepad using the window handle returned by WinWait. Local $PID = WinGetProcess($hWnd) While ProcessExists($PID) MsgBox(0, "ProcessExists", "ProcessExists") ;I do get this msgbox $s_STDOUT = StdoutRead ( $PID ) ConsoleWrite(@LF & $s_STDOUT) ;I don't get anything written to the console If StringInStr($s_STDOUT,"Please reboot your system now",1) Then MsgBox(0, "Reboot", "Reboot now") Sleep(2000) ProcessClose($PID) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", @ScriptName, "REG_SZ", $DestPath & "\Client\UpdateInstaller.exe") ;Shutdown(6) Exit EndIf Wend This is part of what is in the CMD window: Checking Microsoft Security Essentials installation state Restoring screensaver setting... Activating previous power scheme... Deleting temporary power scheme... Installation successful. Please reboot your system now. Ending WSUS Offline Update at 23:02:52.10... C:\Dnload\wsusoffline64bit\client\cmd> Edited October 29, 2017 by Docfxit
Danyfirex Posted November 4, 2017 Posted November 4, 2017 Hello. Check StderrRead help file. Also make sure of run your application with the opt-flags $STDERR_CHILD + $STDOUT_CHILD Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
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