Jump to content

Recommended Posts

Posted (edited)

Hello everyone,

This is my first OFFICIAL post on the example scripts forum as i tend to post only things that might help other people or are advanced enough.

Well i at least hope that someone might find them useful.

It's a list of WMI Tasks concerning several subjects such as Disks, Hardware, Software, Operating System etc. etc.

I hope those functions will come useful and someone might like some of them :)

Opt('MustDeclareVars', 1)

#region
    #NoTrayIcon
    #Include <Array.au3>
#endregion

;====================================================================================
;   Programmed by: Tefkros Pavlou (Gif) ,   www.randomsoft.tk
;       Reference at: http://msdn2.microsoft.com
;           WINMGMTS functions
;====================================================================================

MsgBox(64, 'Mouse Properties', _Mouse_Properties())
MsgBox(64, 'Processor Speed', _Processor_Speed())
MsgBox(64, 'Computer Type', _Computer_Type())
MsgBox(64, 'Total RAM installed', _Physical_RAM_Available())
MsgBox(64, 'Number of Processors', _Number_Of_Processors())
MsgBox(64, 'Floppy check', _Check_Floppy())
MsgBox(64, 'MS Office Version', _Office_GetVersion())
MsgBox(64, 'Operating System Status', _Determine_Operating_System_Status())
MsgBox(64, 'Detailed Date/Time', _Retrieve_Date_And_Time())
MsgBox(64, 'Time Zone', _Get_Time_Zone())
MsgBox(64, 'Username', _Get_Username())

Global $Accounts_Array = _Get_Local_Accounts()
If ($Accounts_Array <> 0) Then _ArrayDisplay($Accounts_Array, 'Local Accounts')

Global $Drives_Array = _Drives_Determine()
If ($Drives_Array <> 0) Then _ArrayDisplay($Drives_Array, 'Drives (determine DVD drives)')

Global $usb_Array = _USB_Devices()
If ($usb_Array <> 0) Then _ArrayDisplay($usb_Array, 'USB Devices')

Global $Logs_Array = _Get_Events_From_Log()
If ($Logs_Array <> 0) Then _ArrayDisplay($Logs_Array, 'Local Accounts')

Global $Startup_Services_Array = _Get_Startup_Services()
If ($Startup_Services_Array <> 0) Then _ArrayDisplay($Startup_Services_Array, 'Startup Items')

Exit (0)

Func _Mouse_Properties()
    Local $a_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_PointingDevice')
        
        Local $Obj_Item
        For $Obj_Item In $Col_Items
            Local $a_Text = 'Description: ' & $Obj_Item.Description & @CRLF
            $a_Text &= 'Device ID: ' & $Obj_Item.DeviceID & @CRLF
            $a_Text &= 'Device Interface: ' & $Obj_Item.DeviceInterface & @CRLF
            $a_Text &= 'Double Speed Threshold: ' & $Obj_Item.DoubleSpeedThreshold & @CRLF
            $a_Text &= 'Handedness: ' & $Obj_Item.Handedness & @CRLF
            $a_Text &= 'Hardware Type: ' & $Obj_Item.HardwareType & @CRLF
            $a_Text &= 'INF File Name: ' & $Obj_Item.InfFileName & @CRLF
            $a_Text &= 'INF Section: ' & $Obj_Item.InfSection & @CRLF
            $a_Text &= 'Manufacturer: ' & $Obj_Item.Manufacturer & @CRLF
            $a_Text &= 'Name: ' & $Obj_Item.Name & @CRLF
            $a_Text &= 'Number Of Buttons: ' & $Obj_Item.NumberOfButtons & @CRLF
            $a_Text &= 'PNP Device ID: ' & $Obj_Item.PNPDeviceID & @CRLF
            $a_Text &= 'Pointing Type: ' & $Obj_Item.PointingType & @CRLF
            $a_Text &= 'Quad Speed Threshold: ' & $Obj_Item.QuadSpeedThreshold & @CRLF
            $a_Text &= 'Resolution: ' & $Obj_Item.Resolution & @CRLF
            $a_Text &= 'Sample Rate: ' & $Obj_Item.SampleRate & @CRLF
            $a_Text &= 'Synch: ' & $Obj_Item.Synch
        Next
        
        Return String($a_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Processor_Speed()
    Local $s_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_Processor')
        
        Local $Obj_Item
        For $Obj_Item In $Col_Items
            Local $s_Text = 'Processor Id: ' & $Obj_Item.ProcessorId & @CRLF
            $s_Text &= 'Maximum Clock Speed: ' & $Obj_Item.MaxClockSpeed
        Next
        
        Return String($s_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Computer_Type()
    Local $u_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Chassis = $Obj_WMIService.ExecQuery('Select * from Win32_SystemEnclosure')
        
        Local $Obj_Chassis
        For $Obj_Chassis In $Col_Chassis
            
            Local $Obj_Items
            For $Obj_Item In $Obj_Chassis.ChassisTypes
                If (Number($Obj_Item) = 1) Then
                    Local $u_Text = 'Type: Other' & @CRLF
                ElseIf (Number($Obj_Item) = 2) Then
                    Local $u_Text = 'Type: Unknown' & @CRLF
                ElseIf (Number($Obj_Item) = 3) Then
                    Local $u_Text = 'Type: Desktop' & @CRLF
                ElseIf (Number($Obj_Item) = 4) Then
                    Local $u_Text = 'Type: Low profile Desktop' & @CRLF
                ElseIf (Number($Obj_Item) = 5) Then
                    Local $u_Text = 'Type: Pizza Box' & @CRLF
                ElseIf (Number($Obj_Item) = 6) Then
                    Local $u_Text = 'Type: Mini Tower' & @CRLF
                ElseIf (Number($Obj_Item) = 7) Then
                    Local $u_Text = 'Type: Tower' & @CRLF
                ElseIf (Number($Obj_Item) = 8) Then
                    Local $u_Text = 'Type: Portable' & @CRLF
                ElseIf (Number($Obj_Item) = 9) Then
                    Local $u_Text = 'Type: Laptop' & @CRLF
                ElseIf (Number($Obj_Item) = 10) Then
                    Local $u_Text = 'Type: Notebook' & @CRLF
                ElseIf (Number($Obj_Item) = 11) Then
                    Local $u_Text = 'Type: Hand Held' & @CRLF
                ElseIf (Number($Obj_Item) = 12) Then
                    Local $u_Text = 'Type: Docking Station' & @CRLF
                ElseIf (Number($Obj_Item) = 13) Then
                    Local $u_Text = 'Type: All in One' & @CRLF
                ElseIf (Number($Obj_Item) = 14) Then
                    Local $u_Text = 'Type: Sub Notebook' & @CRLF
                ElseIf (Number($Obj_Item) = 15) Then
                    Local $u_Text = 'Type: Space saving' & @CRLF
                ElseIf (Number($Obj_Item) = 16) Then
                    Local $u_Text = 'Type: Lunch Box' & @CRLF
                ElseIf (Number($Obj_Item) = 17) Then
                    Local $u_Text = 'Type: Main System Chassis' & @CRLF
                ElseIf (Number($Obj_Item) = 18) Then
                    Local $u_Text = 'Type: Expansion Chassis' & @CRLF
                ElseIf (Number($Obj_Item) = 19) Then
                    Local $u_Text = 'Type: SubChassis' & @CRLF
                ElseIf (Number($Obj_Item) = 20) Then
                    Local $u_Text = 'Type: Bus Expansion Chassis' & @CRLF
                ElseIf (Number($Obj_Item) = 21) Then
                    Local $u_Text = 'Type: Peripheral Chassis' & @CRLF
                ElseIf (Number($Obj_Item) = 22) Then
                    Local $u_Text = 'Type: Storage Chassis' & @CRLF
                ElseIf (Number($Obj_Item) = 23) Then
                    Local $u_Text = 'Type: Rack Mount Chassis' & @CRLF
                ElseIf (Number($Obj_Item) = 24) Then
                    Local $u_Text = 'Type: Sealed-Case PC' & @CRLF
                Else
                    Local $u_Text = 'Type: Unable to retrieve' & @CRLF
                EndIf
            Next
            
            ; Might not work properly
            $u_Text &= 'Name: ' & $Obj_Chassis.Name & @CRLF
            $u_Text &= 'Caption: ' & $Obj_Chassis.Caption & @CRLF
            $u_Text &= 'Manufacturer: ' & $Obj_Chassis.Manufacturer & @CRLF
            $u_Text &= 'Model: ' & $Obj_Chassis.Model & @CRLF
            $u_Text &= 'Description: ' & $Obj_Chassis.Description & @CRLF
            $u_Text &= 'Height: ' & $Obj_Chassis.Height & @CRLF
            $u_Text &= 'Width: ' & $Obj_Chassis.Width & @CRLF
            $u_Text &= 'Weight: ' & $Obj_Chassis.Weight & @CRLF
            $u_Text &= 'Depth: ' & $Obj_Chassis.Depth & @CRLF
            $u_Text &= 'Heat Generation: ' & $Obj_Chassis.HeatGeneration & @CRLF
            $u_Text &= 'Install Date: ' & $Obj_Chassis.InstallDate & @CRLF

        Next
        
        Return String($u_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Physical_RAM_Available()
    Local $y_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_ComputerSystem')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $y_Text = 'RAM: ' & Round((($Obj_Items.TotalPhysicalMemory / 1024) / 1024), 3) & ' MB'
        Next
        
        Return String($y_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Number_Of_Processors()
    Local $z_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_ComputerSystem')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $z_Text = 'Found: ' & $Obj_Items.NumberOfProcessors & ' processor(s)'
        Next
        
        Return String($z_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Drives_Determine()
    Local $Columns = 4
    Local $Number_DRV = DriveGetDrive('CDROM')
    Local $Drives[($Number_DRV[0] + 1)][$Columns]
    $Drives[0][0] = -1
    
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_CDROMDrive')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            $Drives[0][0] += 1
            $Drives[Number($Drives[0][0] + 1)][0] = $Obj_Items.DeviceID
            $Drives[Number($Drives[0][0] + 1)][1] = $Obj_Items.Description
            $Drives[Number($Drives[0][0] + 1)][2] = $Obj_Items.Name
            $Drives[Number($Drives[0][0] + 1)][3] = $Obj_Items.Drive
        Next
        
        $Drives[0][0] += 1
        
        Return $Drives
    Else
        Return 0
    EndIf
EndFunc

Func _USB_Devices()
    Local $Columns = 3
    Local $usb_Array[9][$Columns]
    $usb_Array[0][0] = -1
    
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_USBHub')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            $usb_Array[0][0] += 1
            $usb_Array[Number($usb_Array[0][0] + 1)][0] = $Obj_Items.DeviceID
            $usb_Array[Number($usb_Array[0][0] + 1)][1] = $Obj_Items.PNPDeviceID
            $usb_Array[Number($usb_Array[0][0] + 1)][2] = $Obj_Items.Description
            If (($Obj_Items.Description) <> ($Obj_Items.Name)) Then
                ReDim $usb_Array[Number($usb_Array[0][0] + 1)][$Columns + 1]
                $usb_Array[Number($usb_Array[0][0] + 1)][3] = $Obj_Items.Name
            EndIf
        Next
        
        $usb_Array[0][0] += 1
        
        Return $usb_Array
    Else
        Return 0
    EndIf
    
EndFunc

Func _Check_Floppy()
    Local $m_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery("Select * From Win32_LogicalDisk Where DeviceID = 'A:'")
        
        For $Obj_Items In $Col_Items
            Local $IntFreeSpace = $Obj_Items.FreeSpace
            If (IsNull($IntFreeSpace)) Then
                Local $m_Text = 'No disk in floppy drive.'
            Else
                Local $m_Text = 'Disk found in the floppy drive.'
            EndIf
        Next
        
        Return String($m_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Office_GetVersion()
    Local $h_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_Product ' & _
                'Where IdentifyingNumber ='  _
                 & " '{90280409-6000-11D3-8CFE-0050048383C9}'")
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $h_Text = 'Name: ' & $Obj_Items.Name & @CRLF
            $h_Text &= 'Version: ' & $Obj_Items.Version
        Next
        
        Return String($h_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Get_Startup_Services()
    Local $Columns = 6
    Local $Startup_Services_Array[2][$Columns]
    $Startup_Services_Array[0][0] = 0
    
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_StartupCommand')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            $Startup_Services_Array[0][0] += 1
            $Startup_Services_Array[Number($Startup_Services_Array[0][0])][0] = $Obj_Items.Command
            $Startup_Services_Array[Number($Startup_Services_Array[0][0])][1] = $Obj_Items.Description
            $Startup_Services_Array[Number($Startup_Services_Array[0][0])][2] = $Obj_Items.Location
            $Startup_Services_Array[Number($Startup_Services_Array[0][0])][3] = $Obj_Items.Name
            $Startup_Services_Array[Number($Startup_Services_Array[0][0])][4] = $Obj_Items.SettingID
            $Startup_Services_Array[Number($Startup_Services_Array[0][0])][5] = $Obj_Items.User
            ReDim $Startup_Services_Array[Number($Startup_Services_Array[0][0] + 2)][$Columns]
        Next
        
        $Startup_Services_Array[0][0] += 1
        
        Return $Startup_Services_Array
    Else
        Return 0
    EndIf
EndFunc

Func _Determine_Operating_System_Status()
    Local $j_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_WindowsProductActivation')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Global $Active_Require = $Obj_Items.ActivationRequired
            
            Switch $Active_Require
                Case 0
                    Local $j_Text = 'Activation Not Required' & @CRLF
                Case 1
                    Local $j_Text = 'Activation Is Required' & @CRLF
                Case Else
                    Local $j_Text = 'unknown' & @CRLF
            EndSwitch
            
            $j_Text &= 'Remaining Evaluation Period (in days): ' & $Obj_Items.RemainingEvaluationPeriod & @CRLF
            $j_Text &= 'Remaining Grace Period: (in days): ' & $Obj_Items.RemainingGracePeriod
        Next
        
        Return String($j_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Retrieve_Date_And_Time()
    Local $t_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_LocalTime')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $t_Text = 'Day: ' & $Obj_Items.Day & @CRLF
            $t_Text &= 'Day Of Week: ' & $Obj_Items.DayOfWeek & @CRLF
            $t_Text &= 'Hour: ' & $Obj_Items.Hour & @CRLF
            $t_Text &= 'Minute: ' & $Obj_Items.Minute & @CRLF
            $t_Text &= 'Month: ' & $Obj_Items.Month & @CRLF
            $t_Text &= 'Quarter: ' & $Obj_Items.Quarter & @CRLF
            $t_Text &= 'Second: ' & $Obj_Items.Second & @CRLF
            $t_Text &= 'Week In Month: ' & $Obj_Items.WeekInMonth & @CRLF
            $t_Text &= 'Year: ' & $Obj_Items.Year
        Next
        
        Return String($t_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Get_Time_Zone()
    Local $l_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_TimeZone')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $l_Text = 'Description: ' & $Obj_Items.Description & @CRLF
            $l_Text &= 'Daylight Name: ' & $Obj_Items.DaylightName & @CRLF
            $l_Text &= 'Standard Name: ' & $Obj_Items.StandardName
        Next
        
        Return String($l_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Get_Username()
    Local $p_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_ComputerSystem')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $p_Text = 'Name: ' & $Obj_Items.Name & @CRLF
            $p_Text &= 'Username: ' & $Obj_Items.Username
        Next
        
        Return String($p_Text)
    Else
        Return 0
    EndIf
EndFunc

Func _Get_Local_Accounts()
    Local $Columns = 4
    Local $Local_Accounts_Array[2][$Columns]
    $Local_Accounts_Array[0][0] = 0
    
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_Group  Where LocalAccount = True')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            $Local_Accounts_Array[0][0] += 1
            $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][0] = $Obj_Items.Name
            $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][1] = $Obj_Items.Sid
            Local $Sz_SetType = Number($Obj_Items.SidType)
            
            Select
                Case $Sz_SetType = 1
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'User'
                Case $Sz_SetType = 2
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Group'
                Case $Sz_SetType = 3
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Domain'
                Case $Sz_SetType = 4
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Alias'
                Case $Sz_SetType = 5
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Well Known Group'
                Case $Sz_SetType = 6
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Deleted Account'
                Case $Sz_SetType = 7
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Invalid'
                Case $Sz_SetType = 8
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Unknown'
                Case $Sz_SetType = 9
                    $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][2] = 'Computer'
            EndSelect
            
            $Local_Accounts_Array[Number($Local_Accounts_Array[0][0])][3] = $Obj_Items.Status
            ReDim $Local_Accounts_Array[Number($Local_Accounts_Array[0][0] + 2)][$Columns]
        Next
        
        Return $Local_Accounts_Array
    Else
        Return 0
    EndIf
EndFunc

Func _Get_Events_From_Log()
    Local $Columns = 9
    Local $Events_Array[2][$Columns]
    $Events_Array[0][0] = 0
    
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery("Select * from Win32_NTLogEvent "  _
                 & "Where Logfile = 'System'")
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            $Events_Array[0][0] += 1
            $Events_Array[Number($Events_Array[0][0])][0] = $Obj_Items.Category
            $Events_Array[Number($Events_Array[0][0])][1] = $Obj_Items.ComputerName
            $Events_Array[Number($Events_Array[0][0])][2] = $Obj_Items.EventCode
            $Events_Array[Number($Events_Array[0][0])][3] = $Obj_Items.Message
            $Events_Array[Number($Events_Array[0][0])][4] = $Obj_Items.RecordNumber
            $Events_Array[Number($Events_Array[0][0])][5] = $Obj_Items.SourceName
            $Events_Array[Number($Events_Array[0][0])][6] = $Obj_Items.TimeWritten
            $Events_Array[Number($Events_Array[0][0])][7] = $Obj_Items.Type
            $Events_Array[Number($Events_Array[0][0])][8] = $Obj_Items.User
            ReDim $Events_Array[Number($Events_Array[0][0] + 2)][$Columns]
        Next
        
        Return $Events_Array
    Else
        Return 0
    EndIf
EndFunc

Func _Rename_Computer($iName = @ComputerName)
    Local $z_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_ComputerSystem')
        
        Local $Obj_Items
        For $Obj_Items In $Col_Items
            Local $z_Text = $Obj_Items.Rename(String($iName))
        Next

    EndIf
EndFunc

; Logic IsNull() expression [http://msdn2.microsoft.com/en-us/library/zbchw6hz.aspx]
Func IsNull($g_Var)
    If ((String($g_Var) == '') Or (IsBinary($g_Var)) Or (Not String($g_Var)) Or (StringIsSpace($g_Var)) Or (@error)) Then
        Return True
    Else
        Return False
    EndIf
EndFunc

ps: _Get_Startup_Services() And _Get_Events_From_Log() will take a long time to be executed.

Edited by Gif
Posted

Not bad, I have one suggestion though. Rather than spawn a new WMI object for each Function, why not have a function create 1 and use it against your functions.

Example:

Global $objWMIService

Func WMIService($host) ;Connects to WMI Service
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
    If not IsObj($objWMIService) Then return 0
    return 1
EndFunc

Just my two cents.

Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Posted (edited)

Not bad, I have one suggestion though. Rather than spawn a new WMI object for each Function, why not have a function create 1 and use it against your functions.

Example:

Global $objWMIService

Func WMIService($host) ;Connects to WMI Service
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
    If not IsObj($objWMIService) Then return 0
    return 1
EndFunc

Just my two cents.

Thanks for the reply spudw2k.

If you take a "closer" look you will see that sometimes i use 'winmgmts:\\' & @ComputerName & '\root\cimv2' and other 'winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2'...

Isn't too necessary to create a function to do this...

EDIT: One notice on Get_Startup_Services(), i couldn't use Ubound in redim (don't know why) so i had to redim it on every loop. Plus i couldn't test it too much as it takes about 8-10 minutes to be executed :)

Edited by Gif
Posted

Updated.

Added 2 new functions _Get_Local_Accounts(), _Get_Events_From_Log().

Any more comments?

Posted

If you take a "closer" look you will see that sometimes i use 'winmgmts:\\' & @ComputerName & '\root\cimv2' and other 'winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2'...

I was under the impression that using "{impersonationLevel..." is the preffered method make WMI queries, and I'm pretty sure it won't hurt anything. :) I do like the built queries though. I did one once that grabbed most of the data that systeminfo.exe gets. Good work.

Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Posted (edited)

@CyberZeroCool and spudw2k

Thanks :)

@GaryFrost

Well... this is... just... !!

Edited by Gif
  • 1 month later...
Posted (edited)

I have a question for systeminfo. could you give some idea for getting the information about the system not through wmi, for my having deleted the WMI service from my own system

Edited by netegg
  • 1 month later...
Posted

I have a question for systeminfo. could you give some idea for getting the information about the system not through wmi, for my having deleted the WMI service from my own system

XP or higher - You can try systeminfo.exe, but it may use WMI as well, I'm not sure.

WindowsDir\system32\systeminfo.exe

Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

  • 10 years later...
Posted (edited)

To confirm, _Number_Of_Processors() is supposed to return the socket count? For me It always returns a 1 on my laptop versus the 2 cores and 4 threads (Haven't had a chance to test it on my Dual Socket Server). This isn't supposed to return core or thread count correct?

Edited by Funtime60
Edit 1: Grammar
Posted (edited)

Right.  The NumberOfProcessors property being retrieved from the WMI class that the _Number_Of_Processors function is querying is only capable of showing the Physical Processor count.  If the Processor has multiple cores they are not considered physical processors in themselves.  You can do a query against the Win32_Processor WMI class and inspect the NumberOfCores and NumberofLogicalProcessors properties to determine how many cores and threads respectively are present if desired.

 

Geez, can't believe this thread is over 10 years old. ;p

Edited by spudw2k
Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

  • 4 months later...
Posted (edited)

Could this be used to/modified to get the GUID of the processor?

I should have run it first. It seems it already does this.

Edited by Dent
Not required

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...