# Easiest way to find the screen resolution of all machines on a windows network?

I'd rather not run round checking each machine individually, is there some server-side software I can use? It's a mixed linux/windows network (clients and servers) but I'm only interested in the windows clients.

-

For Windows clients you can use a WMI script to obtain this. The info here should help get you started.

-
Looks good, but how do I get it to run on all client machines in the domain and report back to me? –  Draemon Feb 17 '10 at 11:29
Have a script run at logon that outputs the results to a text file (named with the client computer's name.txt) with the results to a everyone-write-access share? –  Bart Silverstrim Feb 17 '10 at 12:33
It should be easy enough to adapt once you have a list of computer names to start with. Loop through the list and call a sub containing most of the code in that link. Results could go to a file share, be sent via email or logged to a database. But we're getting more into the realm of "how to write VBScript" here, which is probably better covered in a separate question once you've made a decision on which way to go. –  Darth Melkor Feb 17 '10 at 13:22
@mh not really. I know how to write VBScript, but I don't know WMI. What I really meant was "how to run at logon", but I've figured that out. What I didn't realise is that you can do this from one machine given a list of the other machines. –  Draemon Feb 17 '10 at 13:30

Thanks to @mh for the link to WMI. Here's the script I ended up with.

On Error resume next

strDomain = "domain.local"

Set objFSO = CreateObject("Scripting.FileSystemObject")
if err.number <> 0 then Wscript.quit

set domObj = GetObject("WinNT://" & strDomain)
domObj.Filter = Array("computer")
For Each objComputer In domObj
err.clear
strComputer = objComputer.Name
computerName = "UNKNOWN"
loggedOnUser =""
sp = ""
ram = ""
cpu = ""
cpuMhz = ""
xres = ""
yres = ""

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

if err.number=0 then
' Query "BIOS" properties
' computer name
Set colItems = objWMIService.ExecQuery("Select * From Win32_BIOS")
For Each objItem in colItems
computerName = objItem.Path_.Server
Next

' Query Processor properties
' Family
' ...
Set colItems = objWMIService.ExecQuery("Select * From Win32_Processor")
For Each objItem in colItems
cpu = objItem.Manufacturer & " " & objItem.Name
cpuMhz = objItem.MaxClockSpeed
Next

' Query Operating System properties
' SP Level
' RAM
Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
For Each objItem in colItems
sp = objItem.ServicePackMajorVersion
ram = objItem.TotalVisibleMemorySize
Next

' Query Computer System properties
' User
Set colItems = objWMIService.ExecQuery("Select * From Win32_ComputerSystem")
For Each objItem in colItems
Next

' Query Display properties
' Screen resolution
Set colItems = objWMIService.ExecQuery("Select * From Win32_DisplayConfiguration")
For Each objItem in colItems
xres = objItem.PelsWidth
yres = objItem.PelsHeight
Next

strFile = "\\server\data\inventory\" & computerName & ".txt"

Set objTextFile = objFSO.OpenTextFile(strFile, 2, True)
if err.number <> 0 then Wscript.quit

objTextFile.WriteLine("Computer Name: " & strComputer)
if err.number <> 0 then Wscript.quit

if loggedOnUser <> "" then objTextFile.WriteLine("User: " & loggedOnUser)
if cpu <> "" then objTextFile.writeLine("CPU: " & cpu)
if cpuMhz <> "" then objTextFile.writeLine("CPU MHZ: " & cpuMhz)
if ram <> "" then objTextFile.WriteLine("RAM: " & ram)
if sp <> "" then objTextFile.WriteLine("Service Pack: " & sp)
if xres <> "" then objTextFile.WriteLine("Horizontal resolution: " & xres)
if yres <> "" then objTextFile.WriteLine("Vertical resolution: " & yres)

objTextFile.Close

end if
next

-

You can do this via SCOM but it's a big hammer to crack a small nut to be honest.

-