Does anyone know if it is possible and how I could go about retrieving hardware information for Workstations on a network. I've written some VBS which does this on my machine but when I try to retrieve information from another machine on the network the code doesn't work (and to be honest I didn't expect it to) The code I currently have is;
strComputer = inputbox("Please enter the computer name."
' Connect to specified computer
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
' Display error number and description if applicable
If Err Then ShowError
' Header line for screen output
strMsg = vbCrLf & "Hardware summary for " & strComputer & ":" & vbCrLf & vbCrLf
' Enable error handling
On Error Resume Next
' Query processor properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_Processor", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Processor(s)" & vbCrLf _
& " Name: " _
& Strip( objItem.Name ) & vbCrLf _
& " Manufacturer: " _
& objItem.Manufacturer & vbCrLf _
& " Description: " _
& objItem.Description & vbCrLf _
& " Current Clock Speed: " _
& objItem.CurrentClockSpeed & " MHz" _
& vbCrLf & vbCrLf
Next
' Query memory properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_LogicalMemoryConfiguration", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Memory" & vbCrLf _
& " Total Physical Memory: " _
& Int( ( objItem.TotalPhysicalMemory + 1023 ) / 1024 ) _
& " MB" & vbCrLf & vbCrLf
Next
' Query harddisk properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_DiskDrive", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Harddisk(s)" & vbCrLf _
& " Manufacturer: " _
& objItem.Manufacturer & vbCrLf _
& " Model: " _
& objItem.Model & vbCrLf _
& " Size: " _
& Int( ( objItem.Size + 536870912 ) / 1073741824 ) _
& " GB" & vbCrLf & vbCrLf
Next
' Query video adapter properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_VideoController", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Video" & vbCrLf _
& " Name: " _
& objItem.Name & vbCrLf _
& " Description: " _
& objItem.Description & vbCrLf _
& " Video Processor: " _
& objItem.VideoProcessor & vbCrLf _
& " Adapter RAM: " _
& Int( ( objItem.AdapterRAM + 524288 ) / 1048576 ) _
& " MB" & vbCrLf _
& " Video Mode Description: " _
& objItem.VideoModeDescription & vbCrLf & vbCrLf
Next
' Display results
WScript.Echo strMsg
'Done
WScript.Quit(0)
Sub ShowError()
strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & vbCrLf
End Sub
I need to get this to work so that I can access this information for any PC on the network from my PC
Any ideas will be gratefully received
strComputer = inputbox("Please enter the computer name."
' Connect to specified computer
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
' Display error number and description if applicable
If Err Then ShowError
' Header line for screen output
strMsg = vbCrLf & "Hardware summary for " & strComputer & ":" & vbCrLf & vbCrLf
' Enable error handling
On Error Resume Next
' Query processor properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_Processor", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Processor(s)" & vbCrLf _
& " Name: " _
& Strip( objItem.Name ) & vbCrLf _
& " Manufacturer: " _
& objItem.Manufacturer & vbCrLf _
& " Description: " _
& objItem.Description & vbCrLf _
& " Current Clock Speed: " _
& objItem.CurrentClockSpeed & " MHz" _
& vbCrLf & vbCrLf
Next
' Query memory properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_LogicalMemoryConfiguration", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Memory" & vbCrLf _
& " Total Physical Memory: " _
& Int( ( objItem.TotalPhysicalMemory + 1023 ) / 1024 ) _
& " MB" & vbCrLf & vbCrLf
Next
' Query harddisk properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_DiskDrive", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Harddisk(s)" & vbCrLf _
& " Manufacturer: " _
& objItem.Manufacturer & vbCrLf _
& " Model: " _
& objItem.Model & vbCrLf _
& " Size: " _
& Int( ( objItem.Size + 536870912 ) / 1073741824 ) _
& " GB" & vbCrLf & vbCrLf
Next
' Query video adapter properties
Set colItems = objWMIService.ExecQuery( "Select * from Win32_VideoController", , 48 )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objItem in colItems
strMsg = strMsg & "Video" & vbCrLf _
& " Name: " _
& objItem.Name & vbCrLf _
& " Description: " _
& objItem.Description & vbCrLf _
& " Video Processor: " _
& objItem.VideoProcessor & vbCrLf _
& " Adapter RAM: " _
& Int( ( objItem.AdapterRAM + 524288 ) / 1048576 ) _
& " MB" & vbCrLf _
& " Video Mode Description: " _
& objItem.VideoModeDescription & vbCrLf & vbCrLf
Next
' Display results
WScript.Echo strMsg
'Done
WScript.Quit(0)
Sub ShowError()
strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & vbCrLf
End Sub
I need to get this to work so that I can access this information for any PC on the network from my PC
Any ideas will be gratefully received