'==========================================================================
'
' NAME: SetScreenResolution.vbs
'
' AUTHOR: Unknown
' DATE : 6/9/2005
'
' COMMENT: <code posted by cuner on Tek-Tips.com>
'
'==========================================================================
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Hardware profiles\current\system\currentcontrolset\control\video"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
subPath = strKeyPath & "\" & subkey
oReg.EnumKey HKEY_LOCAL_MACHINE, subPath, arrVideoKeys
For Each videoKey In arrVideoKeys
subVideoPath = strKeyPath & "\" & subkey & "\" & videoKey
oReg.EnumValues HKEY_LOCAL_MACHINE, subVideoPath , arrEntryNames, arrValueTypes
If isarray(arrValueTypes) = true Then
'***** reg write****
strEntryName = "DefaultSettings.XResolution"
dwValue = 1024
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath,strEntryName,dwValue
ytrEntryName = "DefaultSettings.YResolution"
dwValue = 768
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath,ytrEntryName,dwValue
rtrEntryName = "DefaultSettings.VRefresh"
dwValue = 75
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath,rtrEntryName,dwValue
' **** end write ****
oReg.EnumKey HKEY_LOCAL_MACHINE, subVideoPath, arrVideoDetailKeys
If isarray(arrVideoDetailKeys) = true Then
For Each videoDetailKey In arrVideoDetailKeys
oReg.EnumValues HKEY_LOCAL_MACHINE, subVideoPath & "\" & videoDetailKey, arrEntryNames, arrValueTypes
'***** reg write****
strEntryName = "DefaultSettings.XResolution"
dwValue = 1024
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath & "\" & videoDetailKey,strEntryName,dwValue
ytrEntryName = "DefaultSettings.YResolution"
dwValue = 768
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath & "\" & videoDetailKey,ytrEntryName,dwValue
rtrEntryName = "DefaultSettings.VRefresh"
dwValue = 75
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath,rtrEntryName,dwValue
' **** end Write ****
Next
Else
End If
Else
End If
Next
Next
strKeyPath2 = "SYSTEM\CurrentControlSet\Hardware profiles\current\system\currentcontrolset\SERVICES"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath2, arrSrvKeys
For Each subkey2 In arrSrvKeys
subPath2 = strKeyPath2 & "\" & subkey2
oReg.EnumKey HKEY_LOCAL_MACHINE, subPath2, arrsVideoKeys
For Each svideoKey In arrsVideoKeys
'***** reg write****
strEntryName = "DefaultSettings.XResolution"
dwValue = 1024
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subPath2 & "\" & svideoKey,strEntryName,dwValue
ytrEntryName = "DefaultSettings.YResolution"
dwValue = 768
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subPath2 & "\" & svideoKey,ytrEntryName,dwValue
rtrEntryName = "DefaultSettings.VRefresh"
dwValue = 75
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath,rtrEntryName,dwValue
' **** end Write ****
subVideoPath2 = strKeyPath2 & "\" & subkey2 & "\" & svideoKey
oReg.EnumKey HKEY_LOCAL_MACHINE, subVideoPath2, arrsVideoDetailKeys
If isarray(arrsVideoDetailKeys) = true Then
For Each svideoDetailKey In arrsVideoDetailKeys
altpath =subVideoPath2 & "\" & svideoDetailkey
'***** reg write****
strEntryName = "DefaultSettings.XResolution"
dwValue = 1024
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath2 & "\" & svideoDetailKey,strEntryName,dwValue
ytrEntryName = "DefaultSettings.YResolution"
dwValue = 768
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath2 & "\" & svideoDetailKey,ytrEntryName,dwValue
rtrEntryName = "DefaultSettings.VRefresh"
dwValue = 75
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,subVideoPath,rtrEntryName,dwValue
' **** end Write ****
Next
Else
End If
Next
Next