Jump to content
Sign in to follow this  
argumentum

[SOLVED] qwinsta.exe not found ?!!

Recommended Posts

..trying to run qwinsta and capture the output, I mean, I can do it from the command prompt but not from code. It tells me 'C:\Windows\System32\qwinsta.exe' is not recognized as an internal or external command but the file is there !.

#include <AutoItConstants.au3>

Example()

Func Example()
    Local $iPID = Run(@ComSpec & " /c C:\Windows\System32\qwinsta.exe", @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
    Local $sOutput = ""
    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
    WEnd
    While 1
        $sOutput &= StderrRead($iPID)
        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf
    WEnd
    ConsoleWrite('>' & $sOutput & '<' & @CRLF)
EndFunc   ;==>Example

anyone knows how to get the info this exe  gives ?

Thanks

Edited by argumentum
SOLVED

Share this post


Link to post
Share on other sites

If you are able to do it from command prompt, did you check the location using the where command? Also try calling the executable directly instead of doing it via ComSpec.


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

#AutoIt3Wrapper_UseX64=y

..that's it.   =) 

..or..

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection ( $bEnable )

if you wanna run 32bit anyway.


Final code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <AutoItConstants.au3>
#include <WinAPIFiles.au3>
#include <Array.au3>

Local $a = Example()

Func Example() ; how to run the x64 when not compiled as x64
    Local $t = TimerInit()
    If StringInStr(@OSArch, "64") Then _WinAPI_Wow64EnableWow64FsRedirection(False)
    Local $iPID = Run(@ComSpec & ' /c "' & @WindowsDir & '\System32\qwinsta.exe"', @WindowsDir & '\System32', @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
    Local $aOutput, $sOutput = ""
    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
    WEnd
    While 1
        $sOutput &= StderrRead($iPID)
        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf
    WEnd
    If StringInStr(@OSArch, "64") Then _WinAPI_Wow64EnableWow64FsRedirection(True) ; needs to be re-enabled ASAP
    If Not StringInStr($sOutput, "SESSIONNAME") Then Return SetError(1, 0, "")
    Local $a, $n, $b, $m, $i = -1
    $b = StringSplit($sOutput, @CRLF, 1)
    Dim $a[UBound($b) + 1][7]
    For $n = 1 To UBound($b) - 1
        If $b[$n] = "" Then ContinueLoop
        $i += 1
        $a[$i][0] = StringMid($b[$n], 1, 1) ; Current
        $a[$i][1] = StringMid($b[$n], 2, 18) ; SESSIONNAME
        $a[$i][2] = StringMid($b[$n], 20, 42 - 20) ; USERNAME
        $a[$i][3] = StringMid($b[$n], 42, 49 - 42) ; ID
        $a[$i][4] = StringMid($b[$n], 49, 57 - 49) ; STATE
        $a[$i][5] = StringMid($b[$n], 57, 69 - 57) ; TYPE
        $a[$i][6] = StringMid($b[$n], 69) ; DEVICE
    Next
    ReDim $a[$i + 1][7]
    For $m = 0 To UBound($a, 2) - 1
        For $n = 0 To UBound($a) - 1
            If $m = 3 And $n Then
                $a[$n][$m] = Int($a[$n][$m])
            Else
                $a[$n][$m] = StringStripWS($a[$n][$m], 3)
            EndIf
        Next
    Next
    $a[0][0] = $i
    _ArrayDisplay($a, "TimerDiff: " & TimerDiff($t))
    Return $a
EndFunc   ;==>Example

may help the next copy'n'paster ( like me )

PS: uploaded to the downloads the utility that gets this array and runs MsTsc to shadow a user.

Edited by argumentum
post the solution

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...