Jump to content

Read command prompt to variable


tlman12
 Share

Recommended Posts

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

Link to comment
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

Link to comment
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

wtfpl-badge-1.png

Link to comment
Share on other sites

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

Link to comment
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

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