Jump to content

Recommended Posts

Hi guys, for educational purpose i want to make a script for read a CMD output and make a progress bar for it

P.S I know the InetGet command, but i have other command-line software based on the same principle

The script:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
 
$GUI = GUICreate("Test", 270, 329, 248, 123)
$List = GUICtrlCreateList("", 8, 8, 249, 227)
GUICtrlSetData(-1, "")
$ProgressBar = GUICtrlCreateProgress(8, 248, 249, 25)
$ButtonStart = GUICtrlCreateButton("Start!", 8, 288, 250, 25)
GUISetState(@SW_SHOW)
 
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $ButtonStart
   Example()
EndSwitch
WEnd

Func Example()
GUICtrlSetData($List, _ReadDos('C:\wget.exe [url="http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"]http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe'[/url]) & @CRLF)
EndFunc
 
Func _ReadDOS($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

The wget link for test:

http://users.ugent.be/~bpuype/cgi-bin/fetch.pl?dl=wget/wget.exe

For me not work, i don't have the list updated. But i see the progress on Console:

Resolving www.autoitscript.com... 87.106.181.57
Connecting to www.autoitscript.com|87.106.181.57|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.autoitscript.com/files/autoit3/autoit-v3-setup.exe [following]
--2012-02-12 09:47:08--  http://www.autoitscript.com/files/autoit3/autoit-v3-setup.exe
Reusing existing connection to www.autoitscript.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 7377952 (7.0M) [application/octet-stream]
Saving to: `autoit-v3-setup.exe.2'
     0K .......... .......... .......... .......... ..........  0% 82.7K 87s
    50K .......... .......... .......... .......... ..........  1%  219K 59s
   100K .......... .......... .......... .......... ..........  2%  280K 48s
   150K .......... .......... .......... .......... ..........  2%  512K 39s
   200K .......... .......... .......... .......... ..........  3%  614K 33s
   250K .......... .......... .......... .......... ..........  4%  513K 30s
   300K .......... .......... .......... .......... ..........  4%  568K 27s
   350K .......... .......... .......... .......... ..........  5%  602K 25s
   400K .......... .......... .......... .......... ..........  6%  615K 23s
   450K .......... .......... .......... .......... ..........  6%  613K 22s
   500K .......... .......... .......... .......... ..........  7%  596K 21s
   550K .......... .......... .......... .......... ..........  8%  612K 20s
   600K .......... .......... .......... .......... ..........  9%  614K 19s
   650K .......... .......... .......... .......... ..........  9%  614K 18s
   700K .......... .......... .......... .......... .......... 10%  597K 18s
   750K .......... .......... .......... .......... .......... 11%  612K 17s
   800K .......... .......... .......... .......... .......... 11%  618K 16s
   850K .......... .......... .......... .......... .......... 12%  612K 16s
   900K .......... .......... .......... .......... .......... 13%  595K 16s
   950K .......... .......... .......... .......... .......... 13%  612K 15s
  1000K .......... .......... .......... .......... .......... 14%  614K 15s
  1050K .......... .......... .......... .......... .......... 15%  611K 14s
  1100K .......... .......... .......... .......... .......... 15%  595K 14s
  1150K .......... .......... .......... .......... .......... 16%  614K 14s
  1200K .......... .......... .......... .......... .......... 17%  617K 14s
  1250K .......... .......... .......... .......... .......... 18%  592K 13s
  1300K .......... .......... .......... .......... .......... 18%  619K 13s
  1350K .......... .......... .......... .......... .......... 19%  611K 13s
  1400K .......... .......... .......... .......... .......... 20%  592K 13s
  1450K .......... .......... .......... .......... .......... 20%  615K 12s
  1500K .......... .......... .......... .......... .......... 21%  613K 12s
  1550K .......... .......... .......... .......... .......... 22%  615K 12s
  1600K .......... .......... .......... .......... .......... 22%  616K 12s
  1650K .......... .......... .......... .......... .......... 23%  595K 12s
  1700K .......... .......... .......... .......... .......... 24%  610K 11s
  1750K .......... .......... .......... .......... .......... 24%  614K 11s
  1800K .......... .......... .......... .......... .......... 25%  615K 11s
  1850K .......... .......... .......... .......... .......... 26%  596K 11s
  1900K .......... .......... .......... .......... .......... 27%  604K 11s
  1950K .......... .......... .......... .......... .......... 27%  624K 11s
  2000K .......... .......... .......... .......... .......... 28%  612K 10s
  2050K .......... .......... .......... .......... .......... 29%  596K 10s
  2100K .......... .......... .......... .......... .......... 29%  610K 10s
  2150K .......... .......... .......... .......... .......... 30%  616K 10s
  2200K .......... .......... .......... .......... .......... 31%  600K 10s
  2250K .......... .......... .......... .......... .......... 31%  614K 10s
  2300K .......... .......... .......... .......... .......... 32%  608K 10s
  2350K .......... .......... .......... .......... .......... 33%  613K 9s
  2400K .......... .......... .......... .......... .......... 34%  598K 9s
  2450K .......... .......... .......... .......... .......... 34%  613K 9s
  2500K .......... .......... .......... .......... .......... 35%  610K 9s
  2550K .......... .......... .......... .......... .......... 36%  615K 9s
  2600K .......... .......... .......... .......... .......... 36%  602K 9s
  2650K .......... .......... .......... .......... .......... 37%  608K 9s
  2700K .......... .......... .......... .......... .......... 38%  616K 9s
  2750K .......... .......... .......... .......... .......... 38%  612K 8s
  2800K .......... .......... .......... .......... .......... 39%  558K 8s
  2850K .......... .......... .......... .......... .......... 40%  659K 8s
  2900K .......... .......... .......... .......... .......... 40%  612K 8s
  2950K .......... .......... .......... .......... .......... 41%  613K 8s
  3000K .......... .......... .......... .......... .......... 42%  599K 8s
  3050K .......... .......... .......... .......... .......... 43%  612K 8s
  3100K .......... .......... .......... .......... .......... 43%  616K 8s
  3150K .......... .......... .......... .......... .......... 44%  615K 8s
  3200K .......... .......... .......... .......... .......... 45%  592K 7s
  3250K .......... .......... .......... .......... .......... 45%  612K 7s
  3300K .......... .......... .......... .......... .......... 46%  612K 7s
  3350K .......... .......... .......... .......... .......... 47%  594K 7s
  3400K .......... .......... .......... .......... .......... 47%  617K 7s
  3450K .......... .......... .......... .......... .......... 48%  615K 7s
  3500K .......... .......... .......... .......... .......... 49%  612K 7s
  3550K .......... .......... .......... .......... .......... 49%  593K 7s
  3600K .......... .......... .......... .......... .......... 50%  614K 7s
  3650K .......... .......... .......... .......... .......... 51%  614K 7s
  3700K .......... .......... .......... .......... .......... 52%  614K 6s
  3750K .......... .......... .......... .......... .......... 52%  596K 6s
  3800K .......... .......... .......... .......... .......... 53%  615K 6s
  3850K .......... .......... .......... .......... .......... 54%  607K 6s
  3900K .......... .......... .......... .......... .......... 54%  617K 6s
  3950K .......... .......... .......... .......... .......... 55%  593K 6s
  4000K .......... .......... .......... .......... .......... 56%  621K 6s
  4050K .......... .......... .......... .......... .......... 56%  608K 6s
  4100K .......... .......... .......... .......... .......... 57%  614K 6s
  4150K .......... .......... .......... .......... .......... 58%  598K 6s
  4200K .......... .......... .......... .......... .......... 58%  612K 5s
  4250K .......... .......... .......... .......... .......... 59%  618K 5s
  4300K .......... .......... .......... .......... .......... 60%  576K 5s
  4350K .......... .......... .......... .......... .......... 61%  629K 5s
  4400K .......... .......... .......... .......... .......... 61%  613K 5s
  4450K .......... .......... .......... .......... .......... 62%  616K 5s
  4500K .......... .......... .......... .......... .......... 63%  597K 5s
  4550K .......... .......... .......... .......... .......... 63%  611K 5s
  4600K .......... .......... .......... .......... .......... 64%  616K 5s
  4650K .......... .......... .......... .......... .......... 65%  612K 5s
  4700K .......... .......... .......... .......... .......... 65%  592K 4s
  4750K .......... .......... .......... .......... .......... 66%  614K 4s
  4800K .......... .......... .......... .......... .......... 67%  612K 4s
  4850K .......... .......... .......... .......... .......... 68%  617K 4s
  4900K .......... .......... .......... .......... .......... 68%  595K 4s
  4950K .......... .......... .......... .......... .......... 69%  611K 4s
  5000K .......... .......... .......... .......... .......... 70%  618K 4s
  5050K .......... .......... .......... .......... .......... 70%  609K 4s
  5100K .......... .......... .......... .......... .......... 71%  599K 4s
  5150K .......... .......... .......... .......... .......... 72%  613K 4s
  5200K .......... .......... .......... .......... .......... 72%  606K 4s
  5250K .......... .......... .......... .......... .......... 73%  621K 3s
  5300K .......... .......... .......... .......... .......... 74%  595K 3s
  5350K .......... .......... .......... .......... .......... 74%  610K 3s
  5400K .......... .......... .......... .......... .......... 75%  616K 3s
  5450K .......... .......... .......... .......... .......... 76%  597K 3s
  5500K .......... .......... .......... .......... .......... 77%  615K 3s
  5550K .......... .......... .......... .......... .......... 77%  612K 3s
  5600K .......... .......... .......... .......... .......... 78%  611K 3s
  5650K .......... .......... .......... .......... .......... 79%  595K 3s
  5700K .......... .......... .......... .......... .......... 79%  612K 3s
  5750K .......... .......... .......... .......... .......... 80%  618K 3s
  5800K .......... .......... .......... .......... .......... 81%  613K 2s
  5850K .......... .......... .......... .......... .......... 81%  582K 2s
  5900K .......... .......... .......... .......... .......... 82%  630K 2s
  5950K .......... .......... .......... .......... .......... 83%  612K 2s
  6000K .......... .......... .......... .......... .......... 83%  609K 2s
  6050K .......... .......... .......... .......... .......... 84%  596K 2s
  6100K .......... .......... .......... .......... .......... 85%  619K 2s
  6150K .......... .......... .......... .......... .......... 86%  609K 2s
  6200K .......... .......... .......... .......... .......... 86%  613K 2s
  6250K .......... .......... .......... .......... .......... 87%  596K 2s
  6300K .......... .......... .......... .......... .......... 88%  612K 2s
  6350K .......... .......... .......... .......... .......... 88%  615K 1s
  6400K .......... .......... .......... .......... .......... 89%  612K 1s
  6450K .......... .......... .......... .......... .......... 90%  597K 1s
  6500K .......... .......... .......... .......... .......... 90%  613K 1s
  6550K .......... .......... .......... .......... .......... 91%  112K 1s
  6600K .......... .......... .......... .......... .......... 92% 98.7M 1s
  6650K .......... .......... .......... .......... .......... 92% 10.0M 1s
  6700K .......... .......... .......... .......... .......... 93% 17.0M 1s
  6750K .......... .......... .......... .......... .......... 94% 54.8M 1s
  6800K .......... .......... .......... .......... .......... 95% 1.22M 1s
  6850K .......... .......... .......... .......... .......... 95%  467K 1s
  6900K .......... .......... .......... .......... .......... 96%  554K 0s
  6950K .......... .......... .......... .......... .......... 97%  612K 0s
  7000K .......... .......... .......... .......... .......... 97%  599K 0s
  7050K .......... .......... .......... .......... .......... 98%  613K 0s
  7100K .......... .......... .......... .......... .......... 99%  609K 0s
  7150K .......... .......... .......... .......... .......... 99%  617K 0s
  7200K .....                                                100%  658K=13s
2012-02-12 09:47:21 (568 KB/s) - `autoit-v3-setup.exe.2' saved [7377952/7377952]

Thanks for support :)

Link to post
Share on other sites

I have found a solurion for wget, but why i can't apply to other?

GUICtrlSetData($ProgressBar, 0)
$CMDDir = $soft & ' "' & $URL & '"'
$CMDCommand = Run($CMDDir, @ScriptDir, @SW_HIDE, $STDERR_CHILD)
ProcessSetPriority($CMDCommand, 0)
$streamcounter = 0
While ProcessExists($CMDCommand)
  If 1 <= $streamcounter Then
   $readstream = StderrRead($CMDCommand)
   $tmp = _StringBetween($readstream, ".....", '%')
   If @error <> 1 Then
    $percent = StringReplace($tmp[0], ".", "");
    $percent = StringStripWS($percent, "7");
    GUICtrlSetData($ProgressBar, $percent)
    GUICtrlSetData($LabelStatus, "Status: Downloading... " & $percent & "%")
   EndIf
   $streamcounter = 0
  EndIf
  $streamcounter = $streamcounter + 1
WEnd
GUICtrlSetData($ProgressBar, 100)
GUICtrlSetState($DownloadButton, $GUI_ENABLE)
GUICtrlSetData($LabelStatus, "Status: Ready")

With StringReplace and StringStripWS remove all the .... and the space, and work. But for another commandline not work :)

Output example:

Connecting ...
Starting download at: 0.000 kB
Metadata:
  duration            11030.68
  moovPosition        32.00
  width              640.00
  height                480.00
  videocodecid        avc1
  audiocodecid        mp4a
  avcprofile            100.00
  avclevel            31.00
  aacaot                2.00
  videoframerate        25.00
  audiosamplerate      48000.00
  audiochannels      2.00
trackinfo:
  length                1103064.00
  timescale          100.00
  language            und
sampledescription:
  sampletype            avc1
  length                529472512.00
  timescale          48000.00
  language            und
sampledescription:
  sampletype            mp4a
399.301 kB / 9.28 sec (0.0%)

So i have make:

GUICtrlSetData($ProgressBar, 0)
$CMDDir = $soft & " -r" & " " & $URL & " " & "-o " & '"' & @WorkingDir & "video.flv" & '"'
$CMDCommand = Run($CMDDir, @ScriptDir, @SW_HIDE, $STDERR_CHILD)
ProcessSetPriority($CMDCommand, 0) ;; lowest
$streamcounter = 0
While ProcessExists($CMDCommand)
  If 1 <= $streamcounter Then
   $readstream = StderrRead($CMDCommand)
   $percent = _StringBetween($readstream, "sec (", "%)")
   If @error <> 1 Then
    GUICtrlSetData($LabelStatus, "Status: Downloading... " & $percent & "%")
    GUICtrlSetData($ProgressBar, $percent) ;; progress bar
   EndIf
   $streamcounter = 0
  EndIf
  $streamcounter = $streamcounter + 1
WEnd
GUICtrlSetData($ProgressBar, 100)
GUICtrlSetState($DownloadButton, $GUI_ENABLE)
GUICtrlSetData($LabelStatus, "Status: Ready)

Status is always ready, i can't understand why.

Please a little help ;)

Thanks for support

Edited by johnmcloud
Link to post
Share on other sites

All command line tools don't give output in same way.

You need to adapt case by case...

You have right, but the second don't give me any output on autoit

$readstream = StdoutRead($CMDCommand)
ConsoleWrite($readstream)

Is empty :)

On classic CMD i see all information. What is the error?

Thanks

EDIT If i use StderrRead and ConsoleWrite, i can see on Console this:

Connecting ...
Starting download at: 0.000 kB
Metadata:
  duration            11030.68
  moovPosition        32.00
  width              640.00
  height                480.00
  videocodecid        avc1
  audiocodecid        mp4a
  avcprofile            100.00
  avclevel            31.00
  aacaot                2.00
  videoframerate        25.00
  audiosamplerate      48000.00
  audiochannels      2.00
trackinfo:
  length                1103064.00
  timescale          100.00
  language            und
sampledescription:
  sampletype            avc1
  length                529472512.00
  timescale          48000.00
  language            und
sampledescription:
  sampletype            mp4a
0.510 kB / 0.00 sec (0.0%)
132.559 kB / 2.40 sec (0.0%)
399.301 kB / 9.28 sec (0.0%)
590.328 kB / 12.28 sec (0.1%)
984.498 kB / 19.12 sec (0.1%)

But the progress bar and the label say 0, i don't know why...

Edited by johnmcloud
Link to post
Share on other sites

Ok, guys, i can figure out how to adapt to another command line.

But i have two problem

1) I can't stop it, during download when i click on close button nothing happens. I have try to make a button with ProcessClose but nothing

2) I don't know how to make a error msgbox in the script

Thanks for support

Link to post
Share on other sites

Ok, guys, i can figure out how to adapt to another command line.

But i have two problem

1) I can't stop it, during download when i click on close button nothing happens. I have try to make a button with ProcessClose but nothing

2) I don't know how to make a error msgbox in the script

Thanks for support

It will be more easy to help you if you show your code... :)

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By zoel
      Hello people, I have a script which calls CMD and executes the netstat command, but when I run it through SCITE the GUI opens but I have no output, How can I run the command as administrator?
      Here is my script so far
      #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> #include <WindowsConstants.au3> #RequireAdmin Local $aWndPos Local $hWnd = GUICreate("Form2", 900, 420, -1, -1, Default + $WS_MAXIMIZE) GUISetBkColor(0xE4E4E4) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idInput = GUICtrlCreateEdit("", 210, 10, 660, 360) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUICtrlSetFont(-1, 10, 400, Default, "COURIER NEW") Local $idButton = GUICtrlCreateButton("NetStat", 10, 10, 190, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idExititem Exit Case $idButton GUICtrlSetData($idInput, _CmdInfo() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) EndSwitch WEnd Func _CmdInfo($_sCmdInfo = "netstat /b") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc  
    • By cruisepandey
      Hi There ! 
      I have a script here : 
       
      ;Launch CMD
      Run("C:\Windows\System32\cmd.exe")
      sleep(2000)
      $cmdHandle = WinActivate("C:\Windows\System32\cmd.exe")
      Sleep(2000)
      ;Sending document
      ControlSend($cmdHandle, "", "", "ftp" & @CRLF)
      ControlSend($cmdHandle, "", "", "open" & @CRLF)
      Sleep(2000)
      ControlSend($cmdHandle, "", "", "first command" & @CRLF)
      Sleep(2000)
      ControlSend($cmdHandle, "", "", "second-coomand" & @CRLF)
       
      first-command and second-command I can't provide cause it's internal. I have complied this .au3 file into an exe and it does the work. But I need to invoke this with Java. Java code I have tried is : 
       
          ProcessBuilder pb = new ProcessBuilder("C:\\Users\\username\\eclipse-workspace\\Examples\\src\\com\\own\\examples\\etc.exe");
          pb.start();
          Thread.sleep(5000);
       
      Through java it just launches the cmd and nothing happens after that. Please help !!
    • By Chimp
      I'm trying to drive a command prompt by sending instructions via a NamedPipe.
      This way you can (should) be able to send commands to the command prompt and at the same time "view" the result in the same window.
      This is not allowed if you run a command prompt with "opt_flag" parameters (redirected streams) because this will disable StdOut on the cmd itself.
      This small (trivial) snippet works for the first command sent to the cmd, but further submissions will fail.
      Maybe the problem is in how I use the run () command to start a new cmd with the StdIn redirect from the NamedPipe. It seems that the generated cmd will close automatically after the first reception of the command via NamedPipe.
      suggestions on how to make it work are welcome
      thanks
      #include <NamedPipes.au3> #include <WinAPI.au3> ; Creates an instance of a named pipe Global $sPipeName = "\\.\pipe\pipename" Global $hPipe = _NamedPipes_CreateNamedPipe($sPipeName, 1, 1) MsgBox(0, "Debug", "Pipe created. Now open a CMD") ; run a cmd with only StdIn redirected (StdIn data incoming from a pipe) Global $hCMD = Run(@ComSpec & " /K cmd < " & $sPipeName & @CRLF, "c:\") ; ok? MsgBox(0, "Debug", "now Send a command to the cmd via a NamedPipe") _StdInPipeWrite("dir" & @CRLF) MsgBox(0, 'Debug', "further commands will fail" & @CRLF & "now send command 'dir c:\windows'") $sMessage = "Dir c:\windows" & @CRLF _StdInPipeWrite($sMessage) MsgBox(0, 'Debug', "send another command (will also fail)" & @CRLF & "now send command 'echo Hello'") _StdInPipeWrite("echo Hello" & @CRLF) MsgBox(0, "Debug", "end of test") ProcessClose($hCMD) Func _StdInPipeWrite($sMessage) ; =============================================================================================================================== ; This function writes a message to the pipe ; =============================================================================================================================== Local $iWritten, $iBuffer, $pBuffer, $tBuffer $iBuffer = StringLen($sMessage) + 1 $tBuffer = DllStructCreate("char Text[" & $iBuffer & "]") $pBuffer = DllStructGetPtr($tBuffer) DllStructSetData($tBuffer, "Text", $sMessage) If Not _WinAPI_WriteFile( _ $hPipe, _ ; ...... Handle to the file to be written $pBuffer, _ ; .... Pointer to the buffer containing the data to be written $iBuffer, _ ; .... Number of bytes to be written to the file $iWritten, _ ; ... The number of bytes written 0 _ ; ............ [optional] A $tagOVERLAPPED structure or a pointer to it ) Then ConsoleWrite("WriteMsg: _WinAPI_WriteFile failed" & @CRLF & _WinAPI_GetLastErrorMessage()) Else ConsoleWrite("WriteMsg: write OK" & @CRLF & _WinAPI_GetLastErrorMessage() & @CRLF) EndIf EndFunc ;==>_StdInPipeWrite  
    • By Burgs
      Greetings,
        I would like to be able to write a script to send commands to the console for creation of Gstreamer pipelines.  I was thinking of something similar to this:
      Local $iPID = Run("C:\Windows\System32\cmd", "", @SW_MAXIMIZE) ;THIS OPENS THE CONSOLE...!!! if $iPID == 0 Then ConsoleWrite(@CRLF & "I DID NOT OPEN CMD...error: " & @error & @CRLF) if $iPID <> 0 Then ConsoleWrite(@CRLF & "I OPENED CMD...!!!" & @CRLF) $hCmd = WinGetHandle("C:\WINDOWS\system32\cmd.exe") if $hCmd <> 0 Then WinActivate($hCmd) ;ensure command console is active... $sOutput = Send("cd C:\gstreamer\1.0\x86_64\bin" & @CRLF, $SEND_RAW) $sOutput = Send("gst-launch-1.0 videotestsrc ! autovideosink" & @CRLF, $SEND_RAW) Sleep(3000) ControlSend($hCmd, "", "", "exit" & @CR) EndIf ;$hCmd NOT "0"... I don't really know if this is the best way to open the console and send commands into it.  I'm also not sure about how to best catch any errors that may occur...likely this needs to be accomplished with the STDOUTREAD command however I've not had experience using it before and therefore would appreciate some advice that anybody may offer. 
      Basically I'm seeking guidance on how to best automate the opening of the console, sending lines of commands to be executed, and handling any potential errors in the execution of those commands...I thank you in advance.  Regards.
    • By MadhaN
      Hi all,
      I have a csv file as below, I wand to find srno from csv and send corresponding ip and pass to commend cmd prompt. 
      Please guide me to create script .
      srno,name,ip,pass
      1,name1,ip1,pass1
      2,name2,ip2,pass2
       
       
       
       
×
×
  • Create New...