Jump to content
Sign in to follow this  
simy8891

Capture a RUN result

Recommended Posts

simy8891

Hi guys,

during the last couple of days I'm struggling with StdoutRead and StderrRead. First of all the Function description isn't that clear.

For my purpose I just need StdoutRead, actually all I want to do is read the output of a command but it doesn't do it as I wish.

Basically all I'm doing is:

- Reading a excel file and put few hostname in an array.

- Ping the hostname, if it's up, then run the wmic, so I want to get the SN of that client.

- Compose a new excel with a list divided in two colums: Hostname | SN

The problem is that the output I read isn't clear at all, I managed to put the readed output in an array but then the string is a bit weird.

All I'd like is to get an array with only 2 positions occupied:

SerialNumber

XXXXXXXX

Instead I'm getting a lot of empty locations in the array (made by the spaces between the "SerialNumber" and "XXXXXXX").

$command=Run($wmic, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)   ;Run the WMIC and capture the stream in $command
         While 1
          $line &= StdoutRead($command)   ;Captured stream is now in $line
          If @error Then ExitLoop
         Wend
         $outputcommand = StringSplit($line, @CRLF, 2)   ;Split the stream in an Array - The array increments everytime.

That's the part of the code were the output is being splitted in the array. Any help would be appreciated.

Thanks ;)

Share this post


Link to post
Share on other sites
water

Why run WMIC and grab the output? You can directly use WMI and get the results. Search the Example Scripts forum for "Scriptomatic".

This script will let you input the WMI query and generates the AutoIt code for you.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×