'usage:
'OpenDocOnMonX <file> <monitor>
'example (opens My Document.txt on monitor 2):
'OpenDocOnMonX "C:\Temp\My Document.txt" 2

Const BROWSER = "%ProgramFiles%\Internet Explorer\iexplore.exe" 'change this to open URLs in a different browser

Const WNDCHANGE_RESIZE_TO_FIT = 1
Const WNDCHANGE_CLIP_TO_WORKSPACE = 2

If WScript.Arguments.Count > 0 Then
	cmd = ""
	file = WScript.Arguments(0)
	If Right(file, 4) = ".url" Then
		Set fso = CreateObject("Scripting.FileSystemObject")
		Set f = fso.OpenTextFile(file, 1, False)
		f.SkipLine
		url = f.ReadLine
		If Left(url, 4) = "URL=" Then
			cmd = """" & BROWSER & """ " & Mid(url, 5)
		End If
	End If
	
	If cmd = "" Then cmd = file
	
	Set util = CreateObject("UltraMon.Utility")
	If util.Run(cmd) = True Then
		If WScript.Arguments.Count = 2 Then
			mon = CLng(WScript.Arguments(1))
			Set wnd = CreateObject("UltraMon.Window")
			If wnd.GetAppMainWindow(util.ProcessId, 10000) = True Then
				wnd.Monitor = mon
				wnd.ApplyChanges WNDCHANGE_RESIZE_TO_FIT Or WNDCHANGE_CLIP_TO_WORKSPACE
			End If
		End If
	End If
End If