Sign in to follow this  
Followers 0
Fukima

Get info from a computer in the same Network.

10 posts in this topic

#1 ·  Posted (edited)

Hi guys, 

 

With the help of the forum I was able to create a code to get computer information from any machine that the script is sitting on. 

My question is can I do such thing with computers in the same local network without having the script on those machines itself?

Here is what I got so far: 

#include-once
#include <array.au3>
#include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include.

; #FUNCTION# ====================================================================================================================
; Name ..........: getcompinfo
; Description ...: Function will get computer info and print to a text file
; Syntax ........: getcompinfo()
; Parameters ....:
; Return values .: None
; Author ........: 
; Modified ......: 01/29/2015
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================









;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Func PcInfo($Message)
    LOCAL $v9dif = round((TimerDiff($v9time)/1000)/60,1)
    $Message = StringLeft( $Message & " <-------------------------",33)
    LOCAL $MessageRaw = $Message & "-> " & @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " - Timer:" & $v9dif
    FileWriteLine($PcInfo, $MessageRaw & @CRLF)
    sleep(1000)
EndFunc

;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Func GetSerial ($serial)
             Dim $BIOS

            _ComputerGetBIOS($BIOS)
            If @error Then
             $error = @error
             $extended = @extended
             Switch $extended
                 Case 1
                     _ErrorMsg($ERR_NO_INFO)
                 Case 2
                     _ErrorMsg($ERR_NOT_OBJ)
             EndSwitch
            EndIf

            For $i = 1 To $BIOS[0][0] Step 1

                $serial = $BIOS[$i][16]

                return $serial
            exitloop    ; not sure why this is a loop, however, this will get you out of the loop or eliminate the while...wend altogether
             Next






EndFunc

;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Func GetModel ($model)

            Dim $Memory

_ComputerGetMemory($Memory)

            If @error Then
             $error = @error
             $extended = @extended
             Switch $extended
                 Case 1
                     _ErrorMsg($ERR_NO_INFO)
                 Case 2
                     _ErrorMsg($ERR_NOT_OBJ)
             EndSwitch
            EndIf


For $i = 1 To $Memory[0][0] Step 1

         $model = $Memory[$i][20]



            return $model
            exitloop    
             Next






EndFunc


func getcompinfo()




FileOpen($FileNamePC,10)






; Check if file opened for writing OK
If $PcInfo = -1 Then
    MsgBox(0, "Error", "Unable to open file the logfile MP510.")
    Exit
EndIf



#Region ---- Software Functions

While 1
    #Region -- Users
    Local $tuff

for $icc = 1 to 80 ; adds header to info
    $tuff &= "-"

next

FileWrite($FileNamePC, $tuff & @CRLF & "Users" & @CRLF & $tuff & @CRLF )

    Dim $Users[1][1]

    _ComputerGetUsers($Users)
    if @error then exit

    ;_arraydisplay($Users)      ; for debugging, comment out if not needed

    For $i = 1 To $Users[0][0] Step 1
        FileWrite($FileNamePC, "Name: " & $Users[$i][0] & @CRLF & _
                "Domain: " & $Users[$i][1] & @CRLF & _
                "Status: " & $Users[$i][2] & @CRLF & _
                "Local Account: " & $Users[$i][3] & @CRLF & _
                "SID: " & $Users[$i][4] & @CRLF & _
                "SIDType: " & $Users[$i][5] & @CRLF & _
                "Description: " & $Users[$i][6] & @CRLF & _
                "Full Name: " & $Users[$i][7] & @CRLF & _
                "Disabled: " & $Users[$i][8] & @CRLF & _
                "Lockout: " & $Users[$i][9] & @CRLF & _
                "Password Changeable: " & $Users[$i][10] & @CRLF & _
                "Password Expires: " & $Users[$i][11] & @CRLF & _
                "Password Required: " & $Users[$i][12] & @CRLF & _
                "Account Type: " & $Users[$i][13]& @CRLF)
    Next
    exitloop    ; not sure why this is a loop, however, this will get you out of the loop or eliminate the while...wend altogether
    #EndRegion -- Users

    #EndRegion ---- Software Functions


WEnd
#Region -- BIOS



FileWrite($FileNamePC, $tuff & @CRLF & "BIOS" & @CRLF & $tuff & @CRLF )


Dim $BIOS

_ComputerGetBIOS($BIOS)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

For $i = 1 To $BIOS[0][0] Step 1
 FileWrite($FileNamePC, "Name: " & $BIOS[$i][0] & @CRLF & _
         "Status: " & $BIOS[$i][1] & @CRLF & _
         "BIOS Characteristics: " & $BIOS[$i][2] & @CRLF & _
         "BIOS Version: " & $BIOS[$i][3] & @CRLF & _
         "Description: " & $BIOS[$i][4] & @CRLF & _
         "Build Number: " & $BIOS[$i][5] & @CRLF & _
         "Code Set: " & $BIOS[$i][6] & @CRLF & _
         "Current Language: " & $BIOS[$i][7] & @CRLF & _
         "Identification Code: " & $BIOS[$i][8] & @CRLF & _
         "Installable Languages: " & $BIOS[$i][9] & @CRLF & _
         "Language Edition: " & $BIOS[$i][10] & @CRLF & _
         "List of Languages: " & $BIOS[$i][11] & @CRLF & _
         "Manufacturer: " & $BIOS[$i][12] & @CRLF & _
         "Other Target OS: " & $BIOS[$i][13] & @CRLF & _
         "Primary BIOS: " & $BIOS[$i][14] & @CRLF & _
         "Release Date: " & $BIOS[$i][15] & @CRLF & _
         "Serial Number: " & $BIOS[$i][16] & @CRLF & _
         "SM BIOS BIOS Version: " & $BIOS[$i][17] & @CRLF & _
         "SM BIOS Major Version: " & $BIOS[$i][18] & @CRLF & _
         "SM BIOS Minor Version: " & $BIOS[$i][19] & @CRLF & _
         "SM BIOS Present: " & $BIOS[$i][20] & @CRLF & _
         "Software Element ID: " & $BIOS[$i][21] & @CRLF & _
         "Software Element State: " & $BIOS[$i][22] & @CRLF & _
         "Target Operating System: " & $BIOS[$i][23] & @CRLF & _
         "Version: " & $BIOS[$i][24] & @CRLF)
Next
#EndRegion -- BIOS




#Region -- Memory

FileWrite($FileNamePC, $tuff & @CRLF & "Memory" & @CRLF & $tuff & @CRLF )

Dim $Memory

_ComputerGetMemory($Memory)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

For $i = 1 To $Memory[0][0] Step 1
 FileWrite($FileNamePC, "Name: " & $Memory[$i][0] & @CRLF & _
         "BankLabel: " & $Memory[$i][1] & @CRLF & _
         "Capacity: " & $Memory[$i][2] & @CRLF & _
         "CreationClassName: " & $Memory[$i][3] & @CRLF & _
         "Description: " & $Memory[$i][4] & @CRLF & _
         "DataWidth: " & $Memory[$i][5] & @CRLF & _
         "DeviceLocator: " & $Memory[$i][6] & @CRLF & _
         "FormFactor: " & $Memory[$i][7] & @CRLF & _
         "HotSwappable: " & $Memory[$i][8] & @CRLF & _
         "InterleaveDataDepth: " & $Memory[$i][9] & @CRLF & _
         "InterleavePosition: " & $Memory[$i][10] & @CRLF & _
         "Manufacturer: " & $Memory[$i][11] & @CRLF & _
         "MemoryType: " & $Memory[$i][12] & @CRLF & _
         "Model: " & $Memory[$i][13] & @CRLF & _
         "OtherIdentifyingInfo: " & $Memory[$i][14] & @CRLF & _
         "PartNumber: " & $Memory[$i][15] & @CRLF & _
         "PositionInRow: " & $Memory[$i][16] & @CRLF & _
         "PoweredOn: " & $Memory[$i][17] & @CRLF & _
         "Removable: " & $Memory[$i][18] & @CRLF & _
         "Replaceable: " & $Memory[$i][19] & @CRLF & _
         "SerialNumber: " & $Memory[$i][20] & @CRLF & _
         "SKU: " & $Memory[$i][21] & @CRLF & _
         "Speed: " & $Memory[$i][22] & @CRLF & _
         "Status: " & $Memory[$i][23] & @CRLF & _
         "Tag: " & $Memory[$i][24] & @CRLF & _
         "TotalWidth: " & $Memory[$i][25] & @CRLF & _
         "TypeDetail: " & $Memory[$i][26] & @CRLF & _
         "Version: " & $Memory[$i][27] & @CRLF)
Next
#EndRegion -- Memory



#Region -- Motherboard

FileWrite($FileNamePC, $tuff & @CRLF & "MotherBoard" & @CRLF & $tuff & @CRLF )


Dim $Motherboard

_ComputerGetMotherboard($Motherboard)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

For $i = 1 To $Motherboard[0][0] Step 1
FileWrite($FileNamePC, "Name: " & $Motherboard[$i][0] & @CRLF & _
         "Availability: " & $Motherboard[$i][1] & @CRLF & _
         "ConfigManagerErrorCode: " & $Motherboard[$i][2] & @CRLF & _
         "ConfigManagerUserConfig: " & $Motherboard[$i][3] & @CRLF & _
         "Description: " & $Motherboard[$i][4] & @CRLF & _
         "CreationClassName: " & $Motherboard[$i][5] & @CRLF & _
         "DeviceID: " & $Motherboard[$i][6] & @CRLF & _
         "ErrorCleared: " & $Motherboard[$i][7] & @CRLF & _
         "ErrorDescription: " & $Motherboard[$i][8] & @CRLF & _
         "LastErrorCode: " & $Motherboard[$i][9] & @CRLF & _
         "PNPDeviceID: " & $Motherboard[$i][10] & @CRLF & _
         "PowerManagementCapabilities: " & $Motherboard[$i][11] & @CRLF & _
         "PowerManagementSupported: " & $Motherboard[$i][12] & @CRLF & _
         "PrimaryBusType: " & $Motherboard[$i][13] & @CRLF & _
         "RevisionNumber: " & $Motherboard[$i][14] & @CRLF & _
         "SecondaryBusType: " & $Motherboard[$i][15] & @CRLF & _
         "Status: " & $Motherboard[$i][16] & @CRLF & _
         "StatusInfo: " & $Motherboard[$i][17] & @CRLF & _
         "SystemCreationClassName: " & $Motherboard[$i][18] & @CRLF & _
         "SystemName: " & $Motherboard[$i][19] & @CRLF)
Next
#EndRegion -- Motherboard


#Region -- Network Cards

FileWrite($FileNamePC, $tuff & @CRLF & "Network Cards" & @CRLF & $tuff & @CRLF )


Dim $NetworkCards

_ComputerGetNetworkCards($NetworkCards)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

For $i = 1 To $NetworkCards[0][0] Step 1
FileWrite($FileNamePC, "Name: " & $NetworkCards[$i][0] & @CRLF & _
         "Adapter Type: " & $NetworkCards[$i][1] & @CRLF & _
         "Adapter Type ID: " & $NetworkCards[$i][2] & @CRLF & _
         "Auto Sense: " & $NetworkCards[$i][3] & @CRLF & _
         "Description: " & $NetworkCards[$i][4] & @CRLF & _
         "Availability: " & $NetworkCards[$i][5] & @CRLF & _
         "Config Manager Error Code: " & $NetworkCards[$i][6] & @CRLF & _
         "Config Manager User Config: " & $NetworkCards[$i][7] & @CRLF & _
         "Creation Class Name: " & $NetworkCards[$i][8] & @CRLF & _
         "Device ID: " & $NetworkCards[$i][9] & @CRLF & _
         "Error Cleared: " & $NetworkCards[$i][10] & @CRLF & _
         "Error Description: " & $NetworkCards[$i][11] & @CRLF & _
         "Index: " & $NetworkCards[$i][12] & @CRLF & _
         "Installed: " & $NetworkCards[$i][13] & @CRLF & _
         "Last Error Code: " & $NetworkCards[$i][14] & @CRLF & _
         "MAC Address: " & $NetworkCards[$i][15] & @CRLF & _
         "Manufacturer: " & $NetworkCards[$i][16] & @CRLF & _
         "Max Number Controlled: " & $NetworkCards[$i][17] & @CRLF & _
         "Max Speed: " & $NetworkCards[$i][18] & @CRLF & _
         "Net Connection ID: " & $NetworkCards[$i][19] & @CRLF & _
         "Net Connection Status: " & $NetworkCards[$i][20] & @CRLF & _
         "Network Addresses: " & $NetworkCards[$i][21] & @CRLF & _
         "Permanent Address: " & $NetworkCards[$i][22] & @CRLF & _
         "PNP Device ID: " & $NetworkCards[$i][23] & @CRLF & _
         "Power Management Capabilities: " & $NetworkCards[$i][24] & @CRLF & _
         "Power Management Supported: " & $NetworkCards[$i][25] & @CRLF & _
         "Product Name: " & $NetworkCards[$i][26] & @CRLF & _
         "Service Name: " & $NetworkCards[$i][27] & @CRLF & _
         "Speed: " & $NetworkCards[$i][28] & @CRLF & _
         "Status: " & $NetworkCards[$i][29] & @CRLF & _
         "Status Info: " & $NetworkCards[$i][30] & @CRLF & _
         "System Creation Class Name: " & $NetworkCards[$i][31] & @CRLF & _
         "System Name: " & $NetworkCards[$i][32] & @CRLF & _
         "Time Of Last Reset: " & $NetworkCards[$i][33] & @CRLF)
Next
#EndRegion -- Network Cards



#Region -- Processors



FileWrite($FileNamePC, $tuff & @CRLF & "Processors" & @CRLF & $tuff & @CRLF )


Dim $Processors

_ComputerGetProcessors($Processors)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

For $i = 1 To $Processors[0][0] Step 1
FileWrite($FileNamePC, "Name: " & $Processors[$i][0] & @CRLF & _
         "Address Width: " & $Processors[$i][1] & @CRLF & _
         "Architecture: " & $Processors[$i][2] & @CRLF & _
         "Availability: " & $Processors[$i][3] & @CRLF & _
         "Description: " & $Processors[$i][4] & @CRLF & _
         "Config Manager Error Code: " & $Processors[$i][5] & @CRLF & _
         "Config Manager User Config: " & $Processors[$i][6] & @CRLF & _
         "CPU Status: " & $Processors[$i][7] & @CRLF & _
         "Creation Class Name: " & $Processors[$i][8] & @CRLF & _
         "Current Clock Speed: " & $Processors[$i][9] & @CRLF & _
         "Current Voltage: " & $Processors[$i][10] & @CRLF & _
         "Data Width: " & $Processors[$i][11] & @CRLF & _
         "Device ID: " & $Processors[$i][12] & @CRLF & _
         "Error Cleared: " & $Processors[$i][13] & @CRLF & _
         "Error Description: " & $Processors[$i][14] & @CRLF & _
         "Ext Clock: " & $Processors[$i][15] & @CRLF & _
         "Family: " & $Processors[$i][16] & @CRLF & _
         "L2 Cache Size: " & $Processors[$i][17] & @CRLF & _
         "L2 Cache Speed: " & $Processors[$i][18] & @CRLF & _
         "Last Error Code: " & $Processors[$i][19] & @CRLF & _
         "Level: " & $Processors[$i][20] & @CRLF & _
         "Load Percentage: " & $Processors[$i][21] & @CRLF & _
         "Manufacturer: " & $Processors[$i][22] & @CRLF & _
         "Max Clock Speed: " & $Processors[$i][23] & @CRLF & _
         "Other Family Description: " & $Processors[$i][24] & @CRLF & _
         "PNP Device ID: " & $Processors[$i][25] & @CRLF & _
         "Power Management Capabilities: " & $Processors[$i][26] & @CRLF & _
         "Power Management Supported: " & $Processors[$i][27] & @CRLF & _
         "Processor ID: " & $Processors[$i][28] & @CRLF & _
         "Processor Type: " & $Processors[$i][29] & @CRLF & _
         "Revision: " & $Processors[$i][30] & @CRLF & _
         "Role: " & $Processors[$i][31] & @CRLF & _
         "Socket Designation: " & $Processors[$i][32] & @CRLF & _
         "Status: " & $Processors[$i][33] & @CRLF & _
         "Status Info: " & $Processors[$i][34] & @CRLF & _
         "Stepping: " & $Processors[$i][35] & @CRLF & _
         "System Creation Class Name: " & $Processors[$i][36] & @CRLF & _
         "System Name: " & $Processors[$i][37] & @CRLF & _
         "Unique ID: " & $Processors[$i][38] & @CRLF & _
         "Upgrade Method: " & $Processors[$i][39] & @CRLF & _
         "Version: " & $Processors[$i][40] & @CRLF & _
         "Voltage Caps: " & $Processors[$i][41] & @CRLF)
Next
#EndRegion -- Processors



#Region -- System
Dim $System

_ComputerGetSystem($System)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg("Array contains no information.")
     Case 2
         _ErrorMsg("$colItems isnt an object.")
 EndSwitch
EndIf


#Region -- System Product
;NOTE: UUID will return 0000's if it is unable to create a UUID.

FileWrite($FileNamePC, $tuff & @CRLF & "System Products" & @CRLF & $tuff & @CRLF )

Dim $SystemProduct

_ComputerGetSystemProduct($SystemProduct)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

For $i = 1 To $SystemProduct[0][0] Step 1
FileWrite($FileNamePC, "Name: " & $SystemProduct[$i][0] & @CRLF & _
         "Identifying Number: " & $SystemProduct[$i][1] & @CRLF & _
         "SKU Number: " & $SystemProduct[$i][2] & @CRLF & _
         "UUID: " & $SystemProduct[$i][3] & @CRLF & _
         "Description: " & $SystemProduct[$i][4] & @CRLF & _
         "Vendor: " & $SystemProduct[$i][5] & @CRLF & _
         "Version: " & $SystemProduct[$i][6] & @CRLF)
Next
#EndRegion -- System Product

#Region -- Video Cards
Dim $VideoCards

_ComputerGetVideoCards($VideoCards)
If @error Then
 $error = @error
 $extended = @extended
 Switch $extended
     Case 1
         _ErrorMsg($ERR_NO_INFO)
     Case 2
         _ErrorMsg($ERR_NOT_OBJ)
 EndSwitch
EndIf

;closes the log file
 FileClose($FileNamePC)

EndFunc


;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Func CheckSystem()
               ; Create a constant variable in Local scope of the filepath that will be read/written to.
            Local Const $sFilePath = "C:\Program Files (x86)"
            Local $iFileExists = FileExists($sFilePath)

            Local $Name = @ComputerName

            Local $win32 = "_" & $Name & "_win32"
            Local $win64 = "_" & $Name & "_win64"

            ; Display a message of whether the file exists or not.
            If $iFileExists Then
               PcInfo("Machine is running Windwos 64 bits")
               return $win64
            Else
               PcInfo("Machine is running Windwos 32 bits")
               return $win32
            EndIf


EndFunc   ;==>CheckSystem

;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Func StoreNumber($store)


            $file = FileOpen("D:\ECM\stations.xml", 0)
            while 1
                $line = FileReadLine($file)
                $global = "glob_store_code="

                $iPosition = StringInStr($line, $global )
                $station = StringMid ( $line, $iPosition + StringLen($global)+4, 3)


                if $iPosition <> 0 then

                    ;MsgBox(0, "test", $line)
                    ;MsgBox(0, "test", $iPosition)
                    ;MsgBox(0, "test", $station)

                Return  $station





                EndIf

            ;ExitLoop
            WEnd
            FileClose($file)

EndFunc




#Region ---- Internal Functions
Func _ErrorMsg($message, $time = 0)
 MsgBox(48 + 262144, "Error!", $message, $time)
EndFunc   ;==>_ErrorMsg
#EndRegion ---- Internal Functions


;Exit

Thank you in advance

Edited by Rorschach

[spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler]

Never compromise even in the face of Armageddon

 

 

[/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler]

Share this post


Link to post
Share on other sites



You'll need to execute the script from the remote pc using something like: PsExec


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

A lot of those values can be read by using WMI!

Search for winmgmts + ExecQuery + Win32_* or seach for Scriptomatic.


Br,
UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I know... you want script to do this.

There are a brazilian tool called CACIC.

It is not script and is open code, but you can get hardware and software information from remote machine and send to a server.

There are anothers similar tools.

I like Scriptomatic and others...

Edited by Detefon

Visit my repository

Share this post


Link to post
Share on other sites

you should read the comments in "your" script

#include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Rorschach,

I would take a real close look at where you have ExitLoop statements.  In your previous thread I used ExitLoop to break you out of an unneccessary while...wend loop.  It appears that you left some of these  in where they should not be ( functions GetSerial, GetModel and CompInfo).

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Rorschach,

I would take a real close look at where you have ExitLoop statements.  In your previous thread I used ExitLoop to break you out of an unneccessary while...wend loop.  It appears that you left some of these  in where they should not be ( functions GetSerial, GetModel and CompInfo).

kylomas

 These functions I am only using to get the name of the file thus the exitloops

 

you should read the comments in "your" script

#include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include.

Never said the code was mine. I said the forum helped me create the code. Good point though.

 

I know... you want script to do this.

There are a brazilian tool called CACIC.

It is not script and is open code, but you can get hardware and software information from remote machine and send to a server.

There are anothers similar tools.

I like Scriptomatic and others...

Thank you for the suggestion but I am trying to keep third party tools out of the equation. 

 

A lot of those values can be read by using WMI!

Search for winmgmts + ExecQuery + Win32_* or seach for Scriptomatic.

Br,

UEZ

 

You'll need to execute the script from the remote pc using something like: PsExec

 

All good ideas guys, thank you very much for the feedback. 


[spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler]

Never compromise even in the face of Armageddon

 

 

[/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I do try to be helpful, and also a dick about it.  Keeps both skills sharp.

I would probably also recommend creating an array of computers and then looping through that.

maybe something like:

$aComps = filereadtoArray("ListOfComputers.txt")

For $i = 0 to UBound($aComps) - 1
    $cI_CompName = $aComps[$i]
    #include "CompInfo.au3"
    
    **rest of your script**
    
Next
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

 

I do try to be helpful, and also a dick about it.  Keeps both skills sharp.

I would probably also recommend creating an array of computers and then looping through that.

maybe something like:

$aComps = filereadtoArray("ListOfComputers.txt")

For $i = 0 to UBound($aComps) - 1
    $cI_CompName = $aComps[$i]
    #include "CompInfo.au3"
    
    **rest of your script**
    
Next

It comes with the territory...It can be a stressful environment at times.

That is a really good suggestion! Thank you very much! 


[spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler][spoiler]

Never compromise even in the face of Armageddon

 

 

[/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler][/spoiler]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Rorschach,

If I were going to "foot print" a system, as you seem to be doing, I would do it like this...

#include <array.au3>

filedelete(@scriptdir & '\wmi010.txt')

local $aHostTable = ['Computer_010',@ComputerName]

local $aClassTable = [ _
                        'Win32_BootConfiguration', _
                        'Win32_DependentService', _
                        'Win32_Desktop', _
                        'Win32_NTEventLogFile', _
                        'Win32_ExtensionInfoAction', _
                        'Win32_Group', _
                        'Win32_LoggedOnUser', _
                        'Win32_OperatingSystem', _
                        'Win32_PrintJob', _
                        'Win32_Process', _
                        'Win32_Service', _
                        'Win32_Share', _
                        'Win32_StartupCommand', _
                        'Win32_Thread', _
                        'Win32_UserAccount', _
                        'Win32_Battery', _
                        'Win32_BIOS', _
                        'Win32_Keyboard', _
                        'Win32_PhysicalMemory', _
                        'Win32_DesktopMonitor', _
                        'Win32_MotherboardDevice', _
                        'Win32_PointingDevice', _
                        'Win32_NetworkAdapter', _
                        'Win32_Printer', _
                        'Win32_Processor', _
                        'Win32_SoundDevice', _
                        'Win32_ComputerSystem', _
                        'Win32_ComputerSystemProduct', _
                        'Win32_VideoController' _
                     ]

for $1 = 0 to UBound($aHostTable) - 1
    filewrite(@scriptdir & '\wmi010.txt', 'Footprinting Host = ' & $aHostTable[$1] & @CRLF)
    for $2 = 0 to UBound($aClassTable) - 1
        splashtexton('Listing WMI Classes for Host = ' & $aHostTable[$1], $aClassTable[$2], -1, 50)
        $str = _WMI($aClassTable[$2],2,default,$aHostTable[$1])
        switch @error
            case 1 to 3
                ConsoleWrite('ERROR Returned from _WMI =  ' & @error & @CRLF)
                exit
            case 4
                $str = 'Unable to connect to Host = ' & $aHostTable[$1] & @CRLF
                filewrite(@scriptdir & '\wmi010.txt',$str)
                exitloop
            case 6
                $str = 'Listing WMI Data for Class = ' & $aClassTable[$2] & @CRLF & 'No Entries Found' & @crlf
        case Else
            $str = 'Listing WMI Data for Class = ' & $aClassTable[$2] & @CRLF & $str & @CRLF
        endswitch
        filewrite(@scriptdir & '\wmi010.txt',$str)
    Next
next

shellexecute(@scriptdir & '\wmi010.txt')

; #FUNCTION# ====================================================================================================================
; Name...........: _WMI
; Description ...: Returns formatted output from a query against any class of the CIMV2 namespace using WMI.
; Syntax.........: _WMI($sWQL, $bReturnType, $sDelimiter, $sTargetPC)
; Parameters ....: $sWQL            - Any class in the WMI CIMV2 namespace (e.g. Win32_Process, Win32_BIOS, Win32_Desktop, etc.)
;                                     or any WQL 'Select' query.  If only the class is specified then all columns
;                                     for all items are returned.
;                  $bReturnType     - Indicates return format.  $bReturnType can be a string or integer.
;                                   |0 - Return a 2D array with item names in col 0 (on the left).
;                                   |1 - Return a 2D array with item names in row 0 (on top).      (DEFAULT)
;                                   |2 - Return a @CRLF delimited string of item names (row #1) followed by items.  Each value is
;                                        delimited by $sDelimiter.
;                  $sDelimiter      - The delimiter used to seperate values/property names within an item.  The default is
;                                     '`' because other common delimiter characters (e.g. '|', ',', '=', ':', '~' etc. appear
;                                     in some values returned by various WQL queries.  This can be a string of characters (e.g. '//').
;                  $sTargetPC       - Name of the PC to run the query on.
; Return values .: Success          - A 2D array or string depending on $bReturnType.
;                  Failure          - Sets @ERROR and returns a value as follows:
;                                   |1 - $sWQL is blank                     Return value - None
;                                   |2 - $bReturnType invalid               Return value - The parm supplied
;                                   |3 - $sDelimiter not specified          Return value - None
;                                   |4 - WMI ObjGet failure                 Return value - None
;                                   |5 - ExecQuery failure                  Return value - $sWQL
;                                   |6 - No items returned                  Return value - $sWQL
;
; Author ........: kylomas
; Modified.......: 02/02/2015 V01R01M01 initial release
; Remarks .......:
; Related .......: WMI is required
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================

Func _WMI($sWQL, $bReturnType = 1, $sDelimiter = '`', $sTargetPC = @ComputerName)

    ; flush parms
    Switch $bReturnType
        Case 0, 1, 2, '0', '1', '2'
        Case -1, Default
            $bReturnType = 1
        Case Else
            Return SetError(2, 0, $bReturnType)
    EndSwitch

    Switch True
        Case $sDelimiter = -1 Or $sDelimiter = Default
            $sDelimiter = '`'
        Case StringLen($sDelimiter) > 0
        Case Else
            Return SetError(3, 0, $sDelimiter)
    EndSwitch

    If StringLen($sWQL) = 0 Then Return SetError(1)
    If StringInStr($sWQL, 'select') = 0 Then $sWQL = 'select * from ' & $sWQL

    ; Get WMI instance
    ; Do NOT use $wbemFlagReturnImmediately or $wbeForwardOnly as this disables the "Count" property
    $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sTargetPC & "\root\CIMV2")
    If Not IsObj($oWMI) Then Return SetError(4)

    ; Run query
    $oItems = $oWMI.ExecQuery($sWQL)
    If Not IsObj($oItems) Then Return SetError(5, 0, $sWQL)
    If $oItems.count = 0 Then Return SetError(6, 0, $sWQL)

    Local $str = ''

    ; format header / use this method as opposed to the "itemindex" method for XP compatibility
    For $oItem In $oItems
        For $P In $oItem.Properties_()
            $str &= '<' & $P.Name & '>' & $sDelimiter
        Next
        $str = StringTrimRight($str, StringLen($sDelimiter)) & @CRLF
        ExitLoop
    Next

    ; format each detail item
    For $oItem In $oItems
        For $P In $oItem.Properties_()
            Switch True
                Case $P.isarray
                    $aTmp1 = $P.Value
                    $str &= _ArrayToString($aTmp1, '') & $sDelimiter
                Case $P.CIMTYPE = 101
                    $str &= CNVTDate($P.Value) & $sDelimiter
                Case Else
                    $str &= $P.Value & $sDelimiter
            EndSwitch
        Next
        $str = StringTrimRight($str, StringLen($sDelimiter)) & @CRLF
    Next
    $str = StringTrimRight($str, 2)

    Switch $bReturnType
        Case '1', 1, -1, Default
            ; return 2D array / column names are at top (row 0)
            Local $aTmp1 = StringSplit($str, @CRLF, 3), $aTmp2
            Local $aRet[UBound($aTmp1)][UBound(StringSplit($aTmp1[0], $sDelimiter, 3))]
            For $1 = 0 To UBound($aTmp1) - 1
                $aTmp2 = StringSplit($aTmp1[$1], $sDelimiter, 3)
                For $2 = 0 To UBound($aTmp2) - 1
                    $aRet[$1][$2] = $aTmp2[$2]
                Next
            Next
            Return $aRet
        Case '0', 0
            ; return 2D array / column names are to the left (col 0)
            Local $aTmp1 = StringSplit($str, @CRLF, 3), $aTmp2
            Local $aRet[UBound(StringSplit($aTmp1[0], $sDelimiter, 3))][UBound($aTmp1)]
            For $1 = 0 To UBound($aTmp1) - 1
                $aTmp2 = StringSplit($aTmp1[$1], $sDelimiter, 3)
                For $2 = 0 To UBound($aTmp2) - 1
                    $aRet[$2][$1] = $aTmp2[$2]
                Next
            Next
            Return $aRet
        Case '2', 2
            ; return string
            Return $str
        Case Else
            Return SetError(7, 0, $bReturnType)
    EndSwitch

EndFunc   ;==>_WMI

Func CNVTDate($dtmDate)
    ; reformat date to mm/dd/yyyy hh:mm:ss and zero fill single digit values
    Return StringRegExpReplace(StringRegExpReplace($dtmDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*', '$2/$3/$1 $4:$5:$6'), '(?<!\d)(\d/)', '0$1')
EndFunc   ;==>CNVTDate

_WMI is a function that I wrote to return WMI data from the CIMv2 namespace in various formats.  This function has two advantages over scriptomatic or CompInfo:

1 - You can easily add/delete WMI classes or even construct your own "select" type queries.

2 - Info can be returned as a delimited string or in array format ( see comments in function header )

This function also corrects two problems that I found:

1 - scriptomatic returns arrays incorrectly

2 - empty date fields return the formatting characters

You can easily reformat the data to whatever your requirements are.

kylomas

edit: add multiple host example

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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