Const DISPLAY_PROFILE_1 = "" 'name only, no path or file extension
Const DISPLAY_PROFILE_2 = ""
Const WALLPAPER_1 = "" 'name only, no path or file extension
Const WALLPAPER_2 = ""
Const NUM_MONS_1 = 0 'number of enabled monitors in this configuration
Const NUM_MONS_2 = 0

Const INSTALL_DIR = "%ProgramFiles%\UltraMon"

If DISPLAY_PROFILE_1 = "" Or DISPLAY_PROFILE_2 = "" Or WALLPAPER_1 = "" Or WALLPAPER_2 = "" Or NUM_MONS_1 = 0 Or NUM_MONS_2 = 0 Then
	MsgBox "Please set the display profiles, wallpapers and number of monitors in the script.",, WScript.ScriptName
	WScript.Quit
End If

'check if UltraMon 3 or later is installed
Set sh = CreateObject("WScript.Shell")
umVer = sh.RegRead("HKLM\Software\Realtime Soft\UltraMon\CurrentVersion")

'get the location of the wallpaper folder(s)
dirProfiles = ""
dirWallpapers = ""
If umVer = "" Then
	'UltraMon 2
	MsgBox "This script requires UltraMon version 3.",,  WScript.ScriptName
	WScript.Quit
Else
	'UltraMon 3 or later
	dirProfiles = sh.ExpandEnvironmentStrings("%APPDATA%\Realtime Soft\UltraMon\" & umVer & "\Profiles")
	dirWallpapers = sh.ExpandEnvironmentStrings("%APPDATA%\Realtime Soft\UltraMon\" & umVer & "\Wallpapers")
End If

Set sys = CreateObject("UltraMon.System")
dispProfile = ""
wallpaper = ""
If sys.NumActiveMonitors = NUM_MONS_1 Then
	dispProfile = DISPLAY_PROFILE_1
	wallpaper = WALLPAPER_1
ElseIf sys.NumActiveMonitors = NUM_MONS_2 Then
	dispProfile = DISPLAY_PROFILE_2
	wallpaper = WALLPAPER_2
End If

If dispProfile <> "" Then
    Set sh = CreateObject("WScript.Shell")
    sh.Run """" & INSTALL_DIR & "\UltraMonShortcuts.exe"" /l " & dirProfiles & "\" & dispProfile & ".umprofile",, True
    WScript.Sleep 3000 'wait a bit to give time for the wallpaper getting refreshed in response to the display config change
    sh.Run """" & INSTALL_DIR & "\UltraMonDesktop.exe"" /load " & dirWallpapers & "\" & wallpaper & ".wallpaper"
End If