Const UM_MIRROR_EXE = "%ProgramFiles%\UltraMon\UMMirrorClient.exe"

Set sh = CreateObject("WScript.Shell")
umVer = CLng(0)
str = sh.RegRead("HKLM\Software\Realtime Soft\UltraMon\CurrentVersion")
If str <> "" Then
	strParts = Split(str, ".")
	str = "&H"
	For i = 0 To 2
		num = Hex(strParts(i))
		If Len(num) = 1 Then num = "0" & num
		str = str & num
	Next
	str = str & "00"
	umVer = CLng(str)	
End If

If umVer >= &H03000300 Then
	'3.0.3 or later
	Set wnd = CreateObject("UltraMon.Window")
	running = wnd.Find("UltraMonMirrorMsgWnd", "UltraMonMirrorMsgWnd", 3, 0, 0)
	If running = True Then
		sh.Run("""" & UM_MIRROR_EXE & """ /stop")
	Else
		sh.Run("""" & UM_MIRROR_EXE & """ /start lastmode")
	End If
Else
	'3.0.2 or earlier
	
	If sh.Run("""" & UM_MIRROR_EXE & """ /start",, True) = 2 Then
		'mirroring already running, stop it
		sh.Run("""" & UM_MIRROR_EXE & """ /stop")
	End If
End If