Const FOLDER = "C:\Program Files" 'folder that should be opened
Const SHOWSTATE = 3 'normal: 2 maximized: 3 desktop-maximized: 4
Const MONITOR = 2 'monitor number
CMD = "" 'set this to the command which should get executed, leave empty to use the default

If CMD = "" Then
	Set sh = CreateObject("WScript.Shell")
	ver = sh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
	verParts = Split(ver, ".")
	verMajor = CLng(verParts(0))
	verMinor = CLng(verParts(1))
	If verMajor < 6 Then
		'XP or earlier
		CMD = "%WINDIR%\explorer.exe /e,," & FOLDER
	Else
		'Vista or later
		CMD = "%WINDIR%\explorer.exe " & FOLDER
	End If
End If

Set util = CreateObject("UltraMon.Utility")
If Util.Run(CMD, SHOWSTATE) = True Then
	util.Sleep 1000
	Set wnd = CreateObject("UltraMon.Window")
	For i = 1 To 20
		If wnd.GetForegroundWindow() = True Then
			If wnd.Class = "ExploreWClass" Or wnd.Class = "CabinetWClass" Then
				j = 0
				Do 
					wnd.Monitor = MONITOR
					wnd.ApplyChanges 2
					If wnd.Monitor = MONITOR Then Exit Do
					util.Sleep 1000
					j = j + 1
				Loop While j < 10
				Exit For
			End If
		End If
		util.Sleep 1000
	Next
End If

