Sign in to follow this  
Followers 0
RogFleming

ShellExecute WMIC STDOUT

5 posts in this topic

Using the Help the following works fine

Local $foo = Run("WMIC.exe"&" "&"/node:dtescan01 Path Win32_Processor GET LoadPercentage","",@SW_HIDE,$STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")

But it slows down the main script having to wait for the Run command to finish

looking for something thing like this to work but right now does not, trying to update a progressbar with a LoadPrecentage value from WMIC

#include <Constants.au3>
GUICreate("OU Admin Monitor",210,85,10,665,$WS_POPUP,$WS_EX_TOPMOST,$sOuadminwin)
$SCAN1UtilLbl = GUICtrlCreateLabel("DTESCAN1 CPU",5,5,200,20)
$SCAN1UtilPb = GUICtrlCreateProgress(5, 25, 200, 20,$PBS_SMOOTH)

ShellExecute("WMIC.exe","node:dtescan01 /Output:STDOUT Path Win32_Processor GET LoadPercentage","","Open",@SW_HIDE)
Local $foo = ProcessExists("wmic.exe")
If @error Then MsgBox(1,"",@error)
Local $line
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    If $Line <> "" Then
    $Scan1cpu = StringInstr($Line,"some sort regexpress to get numeric value from WMIC output",0,0,1)
    GUICtrlSetData($SCAN1UtilLbl, "DTESCAN1 CPU"&" "&$Scan1cpu&"%")
    GUICtrlSetData($SCAN1UtilPb, $Scan1cpu)
    Endif
Wend

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

update code but does not help much

#include <Constants.au3>

Local $foo = Run("WMIC.exe"&" "&"/node:dtescan01 Path Win32_Processor GET LoadPercentage","",@SW_HIDE,$STDOUT_CHILD)
Local $line
While 1
    $line &= StdoutRead($foo)
        If @error Then ExitLoop
    If $line <> "" Then
    MsgBox(1,"",StringRegExp($line,'([0-9]{1,2})'))
    EndIf
Wend
Edited by RogFleming

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

i have tried your last script but it return only one value

how do you want increment your progress bar ?

or may be it's a LoadPercentage "meter"

Edited by wakillon

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

Share this post


Link to post
Share on other sites

i have tried your last script but it return only one value

how do you want increment your progress bar ?

or may be it's a LoadPercentage "meter"

It's load meter the value would be passed and the progressbar would adjust to the current value.

Currently the working model I have is I spawn off a process which sends WMI commands to the remote machine and I update an embeded progressbar.

Looking for a little tighter solution.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It's load meter the value would be passed and the progressbar would adjust to the current value.

Currently the working model I have is I spawn off a process which sends WMI commands to the remote machine and I update an embeded progressbar.

Looking for a little tighter solution.

Seems the standard pipe might be the best way

Run("WMIC.exe"&" "&"/node:dtescan01 Path Win32_Processor GET LoadPercentage >> LoadPercentage.log","",@SW_HIDE)

Then do a While 1

$file = FileExist(LoadPercentage.log)

FileReadLine($file,2)

_FileDelete(LoadPercentage.log)

WEND

Edited by RogFleming

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