Sign in to follow this  
Followers 0
Marcuzzo18

Portable Command Line Tool

2 posts in this topic

#1 ·  Posted (edited)

Hi All,

this is my very first Post. I hope that this could be usefull for some of you.

I wrote this because at times I need to execute commands on the console on a computer where this is blocked.

there are portable cmd tools available non of them seem to have access.

Batch files on the other end work pretty fine,

As I got tired of manually editting a batch file before execution, I decided to write my own console.

cmd2.exe

Edited by Marcuzzo18

[font="Century Gothic"]quisnam est quantum stultus , balatro vel balatro quisnam insistovolubilis in solum rideo risi risum----------------------------------------------------------------------------------------------------------------------------Portable Command Line Tool[/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I don't really have a use for it, but thought this may be useful to others. Here's a gui that does what this script does, but not as cool looking. muttley

#NoTrayIcon

Global $output = ""
$xWin = @DesktopWidth * .5
$yWin = @DesktopHeight * .5

$gui = GUICreate("CMD Tool",$xWin,$yWin,-1,-1)
$inputbox = GUICtrlCreateInput("VER",$xWin * .025,$yWin * .05,$xWin * .875,$yWin * .05)
    GUICtrlSetFont (-1,9, 400, 0, "Arial")
$outputwin = GUICtrlCreateEdit("",$xWin * .025,$yWin * .15,$xWin * .95,$yWin * .8,2048+2097152)
    GUICtrlSetFont (-1,9, 400, 0, "Lucida Console")
$btnGo = GUICtrlCreateButton("GO",$xWin * .925,$yWin * .05,$xWin * .05,$yWin * .05)
    GUICtrlSetState(-1,512)
GUISetState()

While 1
    $msg = GUIGetMsg()

    If $msg = -3 Then ExitLoop
    
    If $msg = $btnGo Then
        $strCMD = GUICtrlRead($inputbox)
        
        $CMD = Run(@Comspec & " /c " & $strCMD,"",@SW_HIDE,6)
        While 1
            $line = StdoutRead($CMD)
            If @error Then ExitLoop
            $output &= $line & @CRLF
        WEnd
        While 1
            $line = StdErrRead($CMD)
            If @error Then ExitLoop
            $output &= $line & @CRLF
        WEnd
        ProcessClose($CMD)

        $output &= "---------------------------------------------------------------------------------------" & @CRLF & @CRLF
        GUICtrlSetData($inputbox,"")
        If StringInstr($output,"") Then
            GUICtrlSetData($outputwin,"")
            $output = ""
        EndIf
        GuiCtrlSetData($outputwin,$output)
        GUICtrlSetState($inputbox,256)
        GUICtrlSetState($btnGo,512)
    EndIf
WEnd

Exit
Edited by spudw2k

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