I modified InstantSupport.au3 so that the IP address could be changed by the user. I have a dynamic IP address that rarely changes, plus I am in the field sometimes when I get a call.
I added a "Connect / Disconnect" button too.
Code: Select all
#include "Aut2Exe\Include\GUIConstantsEx.au3"
#include "Aut2Exe\Include\StaticConstants.au3"
#include "Aut2Exe\Include\WindowsConstants.au3"
; Set our temp working directory.
$TempPath = @TempDir & "\ChunkVNC_Temp_Files"
; Remove any leftovers.
DirRemove( $TempPath, 1 )
; Extract everything.
DirCreate( $TempPath )
FileInstall( "InstantSupport_Files\cad.exe", $TempPath & "\cad.exe", 1 )
FileInstall( "InstantSupport_Files\logo.jpg", $TempPath & "\logo.jpg", 1 )
FileInstall( "InstantSupport_Files\winvnc.exe", $TempPath & "\InstantSupportVNC.exe", 1 )
FileInstall( "InstantSupport_Files\chunkvnc.exe", $TempPath & "\ChunkVNC.exe", 1 )
FileInstall( "InstantSupport_Files\schook.dll", $TempPath & "\schook.dll", 1 )
FileInstall( "InstantSupport_Files\rc4.key", $TempPath & "\rc4.key", 1 )
FileInstall( "InstantSupport_Files\MSRC4Plugin.dsm", $TempPath & "\MSRC4Plugin.dsm", 1 )
FileInstall( "InstantSupport_Files\ultravnc.ini", $TempPath & "\ultravnc.ini", 1 )
FileInstall( "InstantSupport_Files\chunkvnc.ini", $TempPath & "\chunkvnc.ini", 1 )
If Not FileExists($TempPath & "\InstantSupportVNC.exe") Then
MsgBox(266288,"Information","Support files could not be installed."&@CRLF&"Please contact a service representative for instructions.")
_DeleteTemp(5)
Exit
EndIf
; Read the address of the repeater from our settings file.
$RepeaterAddress = IniRead( $TempPath & "\chunkvnc.ini", "Repeater", "Address", "" )
; Generate a random ID number
$LowerLimit = 200000
$UpperLimit = 999999
$RandomNumber = Random( $LowerLimit,$UpperLimit,1 )
; TODO: Check if ID is already in use.
; Create GUI, added text box for repeater address, added button to connect, disconnect
$InstantSupport = GUICreate("Instant Support", 450, 325, 440, 105,BitOR( $WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS,$WS_MINIMIZEBOX ) )
GUISetBkColor( 0xFFFFFF )
$Pic1 = GUICtrlCreatePic($TempPath & "\logo.jpg", 0, 0, 450, 90, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Connection Address:", 16, 112, 181, 28)
GUICtrlSetFont(-1, 14, 400, 0, "Arial Black")
$Input1 = GUICtrlCreateInput($RepeaterAddress, 56, 144, 337, 32)
GUICtrlSetFont(-1, 14, 400, 0, "Arial Black")
$Label2 = GUICtrlCreateLabel($RandomNumber, 0, 192, 450, 100,$SS_CENTER)
GUICtrlSetFont(-1, 50, 800, 0, "Arial Black")
$Button1 = GUICtrlCreateButton("Connect", 40, 296, 387, 25, 0)
GUICtrlSetFont(-1, 12, 800, 0, "Arial Black")
GUISetState(@SW_SHOW)
; Create the tray icon. Default tray menu items (Script Paused/Exit) will not be shown.
Opt( "TrayMenuMode",1 )
$InstallItem = TrayCreateItem( "Install Service" )
; Allocate vars for pid and process
$iToggle = 0
$iPID = 0
; Main Loop
While 1
; Close any windows firewall messages that popup. The windows firewall doesn't block outgoing connections anyways.
if WinExists( "Windows Security Alert" ) then WinClose( "Windows Security Alert" )
; Check for form events.
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
If _Shutdown("Are you sure you want to exit?") = 1 then
_DeleteTemp(5)
Exit
EndIf
Case $Button1
$szRepeaterAddress= GuiCtrlRead($Input1)
If $szRepeaterAddress <> "" Then
$RepeaterAddress = $szRepeaterAddress
IniWrite( $TempPath & "\chunkvnc.ini", "Repeater", "Address", $RepeaterAddress)
EndIf
$iPID = ProcessExists("InstantSupportVNC.exe")
If $iPID Then
If _Shutdown("Are you sure you want to close the connection?") = 1 Then
GuiCtrlSetData($Button1,"Connect")
$iToggle = 0
EndIf
Else
; Start the server and make a reverse connection to the repeater.
ShellExecute( $TempPath & "\InstantSupportVNC.exe", "-autoreconnect ID:" & $RandomNumber & " -connect " & $RepeaterAddress & " -run" )
$iPID = ProcessExists("InstantSupportVNC.exe")
GuiCtrlSetData($Button1,"Disconnect")
$iToggle = 1
EndIf
EndSwitch
; Check for tray events.
$nMsg = TrayGetMsg()
Switch $nMsg
Case $InstallItem
; Choose ID for service installation.
$IDNumber = InputBox( "Service Installation", "Enter an ID number: ", $RandomNumber ) +0
If IsNumber($IDNumber) and $IDNumber > 100000 and $IDNumber < 999999 Then
; Configure ultravnc.ini
IniWrite( $TempPath & "\ultravnc.ini", "admin", "service_commandline", '-autoreconnect ID:' & $IDNumber & ' -connect ' & $RepeaterAddress )
; Configure chunkvnc.ini
IniWrite( $TempPath & "\chunkvnc.ini", "ChunkVNC", "Path", @ProgramFilesDir & '\ChunkVNC' )
IniWrite( $TempPath & "\chunkvnc.ini", "ChunkVNC", "ID", $IDNumber )
; Exit the server.
ShellExecute( $TempPath & "\InstantSupportVNC.exe", "-kill" )
; Run installer after the server exits.
ProcessWaitClose( "InstantSupportVNC.exe", 30 )
ShellExecute( $TempPath & "\ChunkVNC.exe" )
Exit
Else
MsgBox( 0, "Information", "Invalid ID entered, service installation canceled" )
EndIf
EndSwitch
If ProcessExists($iPID) = 0 Then
If $iToggle = 1 Then
GUICtrlSetData($Button1,"Connect")
$iToggle = 0
EndIf
EndIf
WEnd
Func _Shutdown($msg = "")
If $msg = "" Then $msg = "Are you sure you want to quit?"
If MsgBox( 4,"Quit", $msg ) = 6 Then
; Allow viewer to disconnect to prevent schook.dll locking.
If ProcessExists("InstantSupportVNC.exe") Then
MsgBox( 0, "Information", "Please close the viewer now, uninstall will continue in 15 seconds...", 15 )
; Kill the server
ShellExecute( $TempPath & "\InstantSupportVNC.exe", "-kill" )
; Remove files after server closes.
ProcessWaitClose( "InstantSupportVNC.exe", 30 )
EndIf
Return 1
EndIf
Return 0
EndFunc
Func _DeleteTemp( $iDelay = 0 )
Local $sCmdFile
FileDelete( @TempDir & "\scratch.bat" )
$sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
& ':loop' & @CRLF _
& 'rmdir "' & $TempPath & '" /s /q' & @CRLF _
& 'if exist "' & $TempPath & '" goto loop' & @CRLF _ ; Causes high cpu usage if schook.dll is left behind.
& 'del ' & @TempDir & '\scratch.bat'
FileWrite( @TempDir & "\scratch.bat", $sCmdFile )
Run( @TempDir & "\scratch.bat", @TempDir, @SW_HIDE )
FileSetAttrib(@TempDir,"-R+A")
EndFunc
I too had trouble in testing with the directory not being writable, so I remove the read only folder attribute on exit.
Keep up the good work.