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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing screen resolutions...

Status
Not open for further replies.

Ross1811

MIS
Oct 1, 2004
122
US
Hi Everyone,

Is there anyway to change the screen resolution for a windows xp machine to 1024 X 768 with vbscript?


Thanks,
Ross
 
You cna query the settings like this with WMi but i don't believe you can set them.

Code:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayControllerConfiguration",,48)
For Each objItem in colItems
    Wscript.Echo "HorizontalResolution: " & objItem.HorizontalResolution
    Wscript.Echo "VerticalResolution: " & objItem.VerticalResolution
Next

I hope you find this post helpful.

Regards,

Mark
 
i have different computers in my company and i have fix the 1024x768 on all screen with this


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
'*********************** IKINCI KISIM *****************************************************

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top