Jump to content

Recommended Posts

Posted

Could you please guide me why it's wrong in my Run, below?

The command works normally in CMD, but I am not able to transport it to AutoIt.

What I wanted is just to get the result to throw each comma from the CSV into a different variable.

But I'm still stuck on the CMD.

 

The command is = wmic /node:127.0.0.1 ComputerSystem get DNSHostName, ChassisSKUNumber, Domain, Manufacturer, Model, UserName /format:csv | find /v "Name"

 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WINAPI.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

$iPID = Run('wmic /node:127.0.0.1 ComputerSystem get DNSHostName, ChassisSKUNumber, Domain, Manufacturer, Model, UserName /format:csv | find /v "Name"', "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)

ProcessWaitClose($iPID)
$sOutput = StringStripWS(StdoutRead($iPID), $STR_STRIPLEADING + $STR_STRIPTRAILING)

MsgBox(0,0,$sOutput,0)

 

  • Developers
  • Solution
Posted

probably only adding  @COMSPEC /c will do it. (untested)

$iPID = Run(@comspec & ' /c wmic /node:127.0.0.1 ComputerSystem get DNSHostName, ChassisSKUNumber, Domain, Manufacturer, Model, UserName /format:csv | find /v "Name"', "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

@Jos Thanks!

Thanks.
Follow for knowledge the code I'm doing.

As it is, it worked.

But I want it to read from the variable "$sOutputComputerSystem" , without the need to write it in a TXT.

Practicing and studying.

 

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

$iPIDComputerSystem = Run(@comspec & ' /c wmic /node:127.0.0.1 ComputerSystem get DNSHostName, ChassisSKUNumber, Domain, Manufacturer, Model, UserName /format:csv | find /v "Name"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

ProcessWaitClose($iPIDComputerSystem)
$sOutputComputerSystem = StringStripWS(StdoutRead($iPIDComputerSystem), $STR_STRIPLEADING + $STR_STRIPTRAILING)

MsgBox(0,0,$sOutputComputerSystem,0)

FileWrite("C:\test\a.txt",$sOutputComputerSystem)

Global $2dArray

_FileReadToArray("C:\test\a.txt", $2dArray,$FRTA_NOCOUNT,",")

_ArrayDisplay($2dArray)

For $i =1 To UBound($2dArray) -1
    MsgBox(0, '', _
    $2dArray[$i][0])
Next

FileDelete("C:\test\a.txt")

 

Posted

It's more easy!

Thanks so much!

 

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

Global $2dArray

$iPIDComputerSystem = Run(@comspec & ' /c wmic /node:127.0.0.1 ComputerSystem get DNSHostName, ChassisSKUNumber, Domain, Manufacturer, Model, UserName /format:csv | find /v "Name"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

ProcessWaitClose($iPIDComputerSystem)
$sOutputComputerSystem = StringStripWS(StdoutRead($iPIDComputerSystem), $STR_STRIPLEADING + $STR_STRIPTRAILING)

ReadComputerSystem()

Func ReadComputerSystem()
        Local $sOutputComputerSystemR = StringSplit($sOutputComputerSystem, ",")
              For $i = 1 To $sOutputComputerSystemR[0]
                MsgBox($MB_SYSTEMMODAL, "", $i & " " & $sOutputComputerSystemR[$i])

        Next
EndFunc

 

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.
×
×
  • Create New...