Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for checkres.vbs

(view source code of checkres.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim intBpp, intHor, intRC, intVert
  4. Dim colItems, objItem, objWMIService
  5. Dim strQuery
  6.  
  7. intRC   = 0
  8. intBpp  = 0
  9. intHor  = 0
  10. intVert = 0
  11.  
  12. With WScript.Arguments.Unnamed
  13. 	If .Count = 2 Or .Count = 3 Then
  14. 		If IsNumeric( .Item(0) ) Then
  15. 			intHor  = CInt( .Item(0) )
  16. 		Else
  17. 			Syntax
  18. 		End If
  19. 		If IsNumeric( .Item(1) ) Then
  20. 			intVert = CInt( .Item(1) )
  21. 		Else
  22. 			Syntax
  23. 		End If
  24. 		If .Count = 3 Then
  25. 			If IsNumeric( .Item(2) ) Then
  26. 				intBpp = CInt( .Item(2) )
  27. 			Else
  28. 				Syntax
  29. 			End If
  30. 		End If
  31. 	Else
  32. 		Syntax
  33. 	End If
  34. End With
  35.  
  36. strQuery = "SELECT * FROM Win32_DisplayConfiguration"
  37. Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
  38. Set colItems      = objWMIService.ExecQuery( strQuery, "WQL", 48 )
  39. For Each objItem In colItems
  40.       If objItem.PelsWidth  < intHor  Then intRC = 1
  41.       If objItem.PelsHeight < intVert Then intRC = 1
  42.       If objItem.BitsPerPel < intBpp  Then intRC = 1
  43. Next
  44.  
  45. Set colItems      = Nothing
  46. Set objWMIService = Nothing
  47.  
  48. WScript.Quit intRC
  49.  
  50.  
  51. Sub Syntax
  52. 	With WScript
  53. 		.Echo "CheckRes.vbs,  Version 1.01" _
  54. 		    & vbCrLf _
  55. 		    & "Check if the screen resolution meets your minimum requirements" _
  56. 		    & vbCrLf & vbCrLf _
  57. 		    & "Usage:  CSCRIPT  //NoLogo  CHECKRES.VBS  min_hor  min_vert  [ min_bpp ]" _
  58. 		    & vbCrLf & vbCrLf _
  59. 		    & "Where:  ""min_hor""    is the minimum required horizontal resolution in pixels" _
  60. 		    & vbCrLf _
  61. 		    & "        ""min_vert""   is the minimum required vertical resolution in pixels" _
  62. 		    & vbCrLf _
  63. 		    & "        ""min_bpp""    is the minimum required number of bits per pixel" _
  64. 		    & vbCrLf & vbCrLf _
  65. 		    & "Written by Rob van der Woude" _
  66. 		    & vbCrLf _
  67. 		    & "http://www.robvanderwoude.com"
  68. 		.Quit 2
  69. 	End With
  70. End Sub
  71.  

page last modified: 2024-04-16; loaded in 0.0270 seconds