Sign in to follow this  
Followers 0
tlman12

Read command prompt to variable

6 posts in this topic

is there a way to run a command prompt and acruattly read the exact results text to a variable?

Share this post


Link to post
Share on other sites



MsgBox(64, 'Date', _getDOSOutput('date /t'))
Func _getDOSOutput($command)
    Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, '', @SW_HIDE, 2 + 4)
    While 1
        $text &= StdoutRead($Pid, False, False)
        If @error Then ExitLoop
        Sleep(10)
    WEnd
    Return $text
EndFunc ;==>_getDOSOutput


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

MsgBox(64, 'Date', _getDOSOutput('date /t'))
Func _getDOSOutput($command)
    Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, '', @SW_HIDE, 2 + 4)
    While 1
        $text &= StdoutRead($Pid, False, False)
        If @error Then ExitLoop
        Sleep(10)
    WEnd
    Return $text
EndFunc ;==>_getDOSOutput

i'm having the same problem with this one as i did with the one in the help file, it's not returning the results of a dsmove command

Share this post


Link to post
Share on other sites

i'm having the same problem with this one as i did with the one in the help file, it's not returning the results of a dsmove command

What about when you call dsmove directly instead of calling the cmd shell first?

$OUT = ""
$PID = Run('dsmove.exe "CN=Kim Akers,OU=Sales,DC=Contoso,DC=Com" -newname "Kim Ralls"',@SCRIPTDIR,@SW_HIDE,7)
IF $PID THEN
 WHILE 1
    $OUT &= StdoutRead($PID)
    IF @ERROR THEN EXITLOOP
 WEND
ELSE
 $OUT = "Failed to execute program."
ENDIF
MsgBox(64,@SCRIPTNAME,$OUT)

Vlad

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

What about when you call dsmove directly instead of calling the cmd shell first?

$OUT = ""
$PID = Run('dsmove.exe "CN=Kim Akers,OU=Sales,DC=Contoso,DC=Com" -newname "Kim Ralls"',@SCRIPTDIR,@SW_HIDE,7)
IF $PID THEN
 WHILE 1
    $OUT &= StdoutRead($PID)
    IF @ERROR THEN EXITLOOP
 WEND
ELSE
 $OUT = "Failed to execute program."
ENDIF
MsgBox(64,@SCRIPTNAME,$OUT)

Vlad

this probably would work but i eneded up just doing what i needed to do with a series of before and after checks and finished what i needed. but i'll probably put this in because it would make it better to see whether it wouldn't move because of access denied or not found, but i won't be able to check this for a while

thank you everyone for your responses

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  
Followers 0