Recently a new application we are deploying company wide has a specific display resolution requirement. Here is a simple VBScript to show you how to output this to a text file on the local computer. Of course, you could direct this to a specific drive letter, etc. In this example, we’ve actually added the extra process to find a “Tools” directory we locate on each workstation, typically this is the c:\ partition, but it sometimes is a different drive letter. Enjoy:
' Writes screen resolution to the Tools directory
'
' Written by Jason Olson
' Based on work by Microsoft Script Guy
' Find the tools directory, create it if missing
' Get the available logical drives and load them into an array from WMI
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_LogicalDisk Where DriveType = 3")
For Each objItem In colItems
fldrx = objItem.DeviceID & "\Tools\"
set fso = CreateObject("Scripting.FileSystemObject")
if NOT fso.FolderExists(fldrx) Then
fso.CreateFolder (fldrx)
fldcx = True
Exit For
End If
Exit For
Next
' Grab the screen elements
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_DisplayConfiguration")
' Write the data to the tools directory
For Each objItem In colItems
fsa = "Name: " & objItem.DeviceName
fsb = "Color depth: " & objItem.BitsPerPel
fsc = "Horizontal resolution: " & objItem.PelsWidth
fsd = "Vertical resolution: " & objItem.PelsHeight
fsl = fldrx & "screenresolution.txt"
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile(fsl, "8", True)
f.WriteLine(fsa)
f.WriteLine(fsb)
f.WriteLine(fsc)
f.WriteLine(fsd)
f.Close()
Next