;Region Set brake state.
;Set break state so terminating the script is possible without being logged off if the script is not running in logon mode.
;By default Break is set to off.
If Not @LOGONMODE
Break on
EndIf
;endregion
;Region Get screen resolution.
Select
;Get screen resolution for Windows Server 2008.
Case InStr(@PRODUCTTYPE, "Windows Server 2008")
;Get the current screen resolution using WMI.
$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DisplayConfiguration")
For Each $wmiObj in $wmiColl
;Combine width and height.
$screenres = CStr($wmiObj.PelsWidth) + "x" + CStr($wmiObj.PelsHeight)
Next
Case 1
;Get screen resolution for all non-Windows Server 2008 systems.
$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor")
For Each $wmiObj in $wmiColl
;Check if the found resolution is for the primary monitor.
If $wmiObj.DeviceID = "DesktopMonitor1"
;Combine width and height.
$screenres = CStr($wmiObj.ScreenWidth) + "x" + CStr($wmiObj.ScreenHeight)
EndIf
Next
EndSelect
;Region Set wallpaper depending on location, user ID, or system ID.
;Set the wallpaper.
$rc = SetWallpaper("C:\Wallpaper\Wallpaper" + $screenres + ".bmp", 1)
;Set the way the wallpaper is displayed.
;Stretched: WallpaperStyle = 2, TileWallpaper = 0.
;Centered: WallpaperStyle = 0, TileWallpaper = 0.
;Tiled: WallpaperStyle = 0, TileWallpaper = 1.
$rc = WriteValue("HKU\" + @SID + "\Control Panel\Desktop", "TileWallpaper", "0", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Control Panel\Desktop", "WallpaperStyle", "2", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "TileWallpaper", "0", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "WallpaperStyle", "2", "REG_SZ")
;Set background color to greenish blue. Use RGB values for the color.
$rc = WriteValue("HKCU\Control Panel\Colors", "Background", "29 95 122", "REG_SZ")