Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dppeee.vbs

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

  1. Option Explicit
  2.  
  3. If WScript.Arguments.Count > 0 Then Syntax
  4.  
  5. Dim intXRes, intYRes
  6. Dim colItems, objFSO, objItem, objWMIService, wshShell
  7. Dim strDPPExec, strDPPPath
  8.  
  9. Set wshShell = CreateObject( "WScript.Shell" )
  10. Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  11.  
  12. ' Find the path to the DPP executable
  13. strDPPPath = wshShell.RegRead( "HKEY_LOCAL_MACHINE\SOFTWARE\Canon\DPP\InstallPath" )
  14. strDPPExec = """" & objFSO.BuildPath( strDPPPath, "DPPViewer.exe" ) & """"
  15.  
  16. ' Check the current screen resulution
  17. Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
  18. Set colItems      = objWMIService.ExecQuery( "Select * from CIM_VideoController", , 48 )
  19. For Each objItem in colItems
  20. 	If Not IsNull( objItem.CurrentHorizontalResolution ) Then
  21. 		intXRes = CInt( objItem.CurrentHorizontalResolution )
  22. 		intYRes = CInt( objItem.CurrentVerticalResolution )
  23. 	End If
  24. Next
  25. Set colItems      = Nothing
  26. Set objWMIService = Nothing
  27.  
  28. ' Set the screen resolution to 1024x768 only if necessary
  29. If Not IsNull( intXRes ) Then
  30. 	If intXRes <> 1024 Or intYRes <> 768 Then
  31. 		On Error Resume Next
  32. 		wshShell.Run "SetRes.exe m0:0 h1024 v768", 6, True
  33. 		If Err Then Syntax
  34. 		On Error Goto 0
  35. 	End If
  36. End If
  37.  
  38. ' Run the DPP program
  39. wshShell.Run strDPPExec, 3, True
  40.  
  41. ' Restore the original screen resolution if necessary
  42. If Not IsNull( intXRes ) Then
  43. 	If intXRes <> 1024 Or intYRes <> 768 Then
  44. 		On Error Resume Next
  45. 		wshShell.Run "SetRes.exe m0:0 h" & intXRes & " v" & intYRes, 6, False
  46. 		On Error Goto 0
  47. 	End If
  48. End If
  49.  
  50. Set objFSO   = Nothing
  51. Set wshShell = Nothing
  52.  
  53.  
  54. Sub Syntax
  55. 	Dim strMsg
  56. 	strMsg = vbCrLf _
  57. 	       & "DPPEEE.vbs,  Version 1.11" _
  58. 	       & vbCrLf _
  59. 	       & "Temporarily change the screen resolution to 1024x768 on a netbook PC to allow" _
  60. 	       & vbCrLf _
  61. 	       & "running Canon Digital Photo Professional software." _
  62. 	       & vbCrLf & vbCrLf _
  63. 	       & "Usage:  DPPEEE.VBS" _
  64. 	       & vbCrLf & vbCrLf _
  65. 	       & "Notes:  Requires Ian Sharpe's SetRes (http://www.iansharpe.com/downloads.php)" _
  66. 	       & vbCrLf _
  67. 	       & "        Script can easily be modified for other software requiring 1024x768." _
  68. 	       & vbCrLf & vbCrLf _
  69. 	       & "Written by Rob van der Woude" _
  70. 	       & vbCrLf _
  71. 	       & "http://www.robvanderwoude.com"
  72. 	WScript.Echo strMsg
  73. 	WScript.Quit 1
  74. End Sub
  75.  

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