simy8891 Posted May 25, 2012 Share Posted May 25, 2012 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 Link to comment Share on other sites More sharing options...
water Posted May 25, 2012 Share Posted May 25, 2012 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now