Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to determine resoltion and run .exe depending on it 1

Status
Not open for further replies.

uclavs2

Programmer
Aug 1, 2010
1
NL
Hi there,

I would like a VBScript to determine the screen resolution and run a specific .exe file depending on the resolution.

For example I want example1.exe to be executed if the resolution is 1440 x 900 and example2.exe if the resolution is 1024 x 769.

Can anyone help me? I have no idea where to start.

Thanks in advance
 
Win32_VideoController and Win32_VideoSettings?
 
this might be what is available, not what is currently set

Option Explicit
Dim strComputer, objWMIService, colVCR, objRes
Dim objElement, objSetting
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colVCR = objWMIService.ExecQuery("SELECT * FROM Win32_VideoSettings")

For Each objRes In colVCR
Set objElement = GetObject("winmgmts:" & objRes.Element)
If objElement.DeviceID = "VideoController1" Then
Set objSetting = GetObject("winmgmts:" & objRes.Setting)
Wscript.Echo objSetting.HorizontalResolution & " " & objSetting.VerticalResolution & " " & objSetting.NumberOfColors & " " & objSetting.Refreshrate
Set objSetting = Nothing
End If
Set objElement = Nothing
Next

Set objWMIService = Nothing
Set colVCR = Nothing
 
Code:
[blue]Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
Set colMonitors = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'", , 0)
For Each Monitor In colMonitors
    xres = Monitor.ScreenWidth
    yres = Monitor.ScreenHeight
Next
MsgBox "Resolution of primary monitor is " & xres & " x " & yres[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top