Jump to content

Recommended Posts

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)
   ; 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")
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", @ScriptName, "REG_SZ", $DestPath & "\Client\UpdateInstaller.exe")

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...



Edited by Docfxit
Link to post
Share on other sites

Hello. Check StderrRead help file. Also make sure of run your application with the opt-flags $STDERR_CHILD + $STDOUT_CHILD






Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...