Jump to content

Running console with either $STDIN_CHILD or $STDOUT_CHILD hides output.


Recommended Posts

Hi, as the title says, whenever i use $STDIN_CHILD or $STDOUT_CHILD or both together, console output is hidden. (using @SW_SHOW of course)

It's weird as i remember that some time ago it showed no problem, something has changed, but i have no idea what, maybe a windows update could do it?

So i ask for your help to try a script and post your results. This script works fine here, and it can read the console output, it's just that i can't.

On a side note i noticed that if i use "conhost" instead of "cmd", it shows, even if the output from StdoutRead is a bit messed up, i assume because of encoding to ANSI.

#include <Constants.au3>
Global $begin = 0, $dif = 0
PcInfo()
;======================================================================================
Func PcInfo()
    Local $DSK, $Read, $Str, $Str1, $Spl, $SplR, $SplR2, $SplR3
    $DSK = Run('cmd', @ScriptDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD )
    Sleep(3000);Sleep a bit so we can take a good look at the cmd window empty.. or not.
    Do
        $Read = StdoutRead($DSK, True, False)
        $Str = StringInStr($Read, 'Microsoft Windows')
    Until $Str <> 0
    StdinWrite($DSK, "wmic baseboard get product,manufacturer" & @CRLF)
    $begin = TimerInit()
    Do
        $dif = TimerDiff($begin)
        $Read = StdoutRead($DSK, True, False)
        $Str1 = StringInStr($Read, 'Manufacturer', 0, 2)
        If $dif >= 2000 Then ExitLoop
    Until $Str1 <> 0
    Sleep(100)
    $Read = StdoutRead($DSK, True, False)
    $Spl = StringSplit($Read, 'Product', 1)
    If $Spl <> @error Then
        $SplR = StringLeft($Spl[2], StringInStr($Spl[2], @CRLF, 0, -1))
        $SplR = StringStripWS($SplR, 7)
    Else
        $SplR2 = 'NULL'
    EndIf
    StdioClose($DSK)
    Sleep(100)
    MsgBox(64, 'Information', $SplR & @CRLF)
EndFunc   ;==>PcInfo
;=============================================================================

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

You must make it CUI and compile it.  Then it will show in DOS console otherwise Scite will take care of it ;)

Use _WinAPI_OemToChar () to convert the DOS output.

Edited by Nine
Link to comment
Share on other sites

When did that change happened? I remember clearly, to be able to see the console output without compiling.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

I appreciate your input, tried compiling using:

#AutoIt3Wrapper_Change2CUI=y

and

#pragma compile(Console, true)

and get the same result, nothing visible, code works and reads console output, but it's all hidden from me, only the terminal window shows up empty.

I would appreciate if more people could confirm this.

Im 90% sure that some time ago i was able to simply change the flag to show, and i could see the cmd window output in real time, i did at least one function entirely based on this that gets some information about the pc, motherboard version, cpu and graphic card. I did a lot of debugging and never had to compile as a console, i remember that after i was done with the function, all i did was change the flag back to hide and that was it.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Try this :

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinAPIConv.au3>
#include <Constants.au3>

Opt("MustDeclareVars", 1)

Local $vData

Local $iPID = Run("cmd.exe", "", @SW_SHOW, $STDIN_CHILD+$STDOUT_CHILD)
ProcessWait($iPID)
MsgBox ($MB_SYSTEMMODAL,"",ReadStream ($iPID))

StdinWrite ($iPID, "DIR" & @CRLF)
MsgBox ($MB_SYSTEMMODAL,"",ReadStream ($iPID))

StdinWrite ($iPID, "Type run.au3" & @CRLF)
MsgBox ($MB_SYSTEMMODAL,"",ReadStream ($iPID))

Func ReadStream ($iPID)
  Local $vData, $sStream
  Do
    Sleep (300)
    $vData = StdoutRead($iPID)
    If @error Then
      StdioClose($iPID)
      ProcessClose($iPID)
      Exit ConsoleWrite("[ERROR]" & @error & " / " & @extended & @CRLF)
    EndIf
    ConsoleWrite($vData & @CRLF)
    $sStream &= $vData
  Until $vData = ""
  Return _WinAPI_OemToChar ($sStream)
EndFunc

Compile it and run it.

Link to comment
Share on other sites

Your code works. Can you test this pls?

#AutoIt3Wrapper_Change2CUI=y
#include <Constants.au3>
Opt("MustDeclareVars", 1)
Local $iPID = Run("cmd.exe", '', @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
ProcessWait($iPID)
Sleep(3000)
Exit

With this there's absolutely no output, am i wrong to assume there should be at least the usual Microsoft Windows version blah blah?

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

That won't work. I see now where you are mixing up the functioning of the stream.  CMD.exe cannot send at 2 different places the same stream.  So it sends with consoleWrite, and it is captured by the script.  It is impossible to send it somewhere else, since we are hook to its stream.  The fact that it is showing in a DOS console, it is because the script writes to it in CUI mode.  I do not believe there is any other possibilities.  Of course, I could be wrong, it happened in the past...

Edited by Nine
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...