Sign in to follow this  
Followers 0
_Chris_

IP Changing and Monitoring for Remote Assistance

2 posts in this topic

Hi, im writing a script to change a computers ip address based on which option is selected, its for a remote assistance program which port forwards to ip addresses depending on which file the client loads. I am using a do until command to monitor activities of IP addresses to see which ones are free (Using PING). I cant seem to get other commands to run properly whilst this is happening, i assume because the program is busy running the pings. Code below. Any ideas on how i can get the program to close as soon as i push the exit button, instead of waiting ages. Also the button dosent seem to run the function, presumably for the same reason. HELP!

#include <GUIConstants.au3>
#include <Process.au3>
Opt("OnExitFunc", "closeclicked")
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGui")

TraySetState (2)

#region INI File Variables
$NETCONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Network", "Connection", "ERROR" )
$Gateway = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Network", "Gateway", "ERROR" )
$DNS1CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Network", "DNS1", "ERROR" )
$DNS2CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Network", "DNS2", "ERROR" )
$MASKCONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Network", "Mask", "ERROR" )

$REM1CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Remote1", "IP", "ERROR" )
$REM2CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Remote2", "IP", "ERROR" )
$REM3CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Remote3", "IP", "ERROR" )
$REM4CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Remote4", "IP", "ERROR" )
$REM5CONFIG = IniRead ( "C:\Program Files\Advantig\DualDesk Viewer\TTconfig.ini", "Remote5", "IP", "ERROR" )
#endregion

#region Splash Screen
$SSST = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
GUICtrlCreateLabel("Starting Remote Assistance Software",10,15,180,40)
GUISetState(@SW_SHOW,$SSST)
_RunDos('netsh interface ip set address name="'&$NETCONFIG&'" dhcp')
_RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" dhcp')
GUIDelete($SSST)
#endregion Splash Screen
#region Main Form
$Main = GUICreate("| Target Tracker Remote Support Console |", 570, 295, -1, -1)
                GUISetBkColor(0xFFFFFF)
                GUISetState(@SW_SHOW,$Main)
                GUISetFont (12, 400)
                GUICtrlCreatePic("pic.bmp",310,15,260,269)

$Group1 = GUICtrlCreateGroup("Please Select a Remote Assistance Channel ", 8, 6, 290, 280, $WS_CLIPSIBLINGS)
GUICtrlSetFont (-1,9, 400)
$REM1 = GUICtrlCreateRadio("Remote Assistance 1 (Port 433)", 32, 30, 255, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM1S = GUICtrlCreateLabel("Status:", 80, 50, 150, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM2 = GUICtrlCreateRadio("Remote Assistance 2 (Port 110)", 32, 70, 255, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM2S = GUICtrlCreateLabel("Status:", 80, 90, 150, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM3 = GUICtrlCreateRadio("Remote Assistance 3 (Port 443)", 32, 110, 255, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM3S = GUICtrlCreateLabel("Status:", 80, 130, 150, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM4 = GUICtrlCreateRadio("Remote Assistance 4 (Port 143)", 32, 150, 255, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM4S = GUICtrlCreateLabel("Status:", 80, 170, 150, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM5 = GUICtrlCreateRadio("Remote Assistance 5 (Port 119)", 32, 190, 255, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$REM5S = GUICtrlCreateLabel("Status:", 80, 210, 150, 17)
                GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
                
$Help = GUICtrlCreateButton("Help", 32, 245, 118, 25, 0)
$Start = GUICtrlCreateButton("Start", 156, 245, 118, 25, 0)
GUICtrlSetOnEvent(-1,"StartListening")
Call("NoNetwork")
#endregion Main Form

#region Do Until Close Statment
Do
    $msg=GUIGetMsg()
    
    $REM1R= GUICtrlRead($REM1)
    $REM2R= GUICtrlRead($REM2)
    $REM3R= GUICtrlRead($REM3)
    $REM4R= GUICtrlRead($REM4)
    $REM5R= GUICtrlRead($REM5)
    
    $NETCHECK=Ping($Gateway,250)
        
    if $NETCHECK Then
    
    $PREM1 = Ping($REM1CONFIG,250)
    $PREM2 = Ping($REM2CONFIG,250)
    $PREM3 = Ping($REM3CONFIG,250)
    $PREM4 = Ping($REM4CONFIG,250)
    $PREM5 = Ping($REM5CONFIG,250)
    
    if $PREM1 Then
    GUICtrlSetState ( $REM1, $GUI_DISABLE)
    GUICtrlSetState ( $REM1S, $GUI_DISABLE)
    GUICtrlSetData ( $REM1S,"Status: Busy")
    Else
    GUICtrlSetState ( $REM1, $GUI_ENABLE)
    GUICtrlSetState ( $REM1S, $GUI_ENABLE)
    GUICtrlSetData ( $REM1S,"Status: Free")
    Endif
    
    if $PREM2 Then
    GUICtrlSetState ( $REM2, $GUI_DISABLE)
    GUICtrlSetState ( $REM2S, $GUI_DISABLE)
    GUICtrlSetData ( $REM2S,"Status: Busy")
    Else
    GUICtrlSetState ( $REM2, $GUI_ENABLE)
    GUICtrlSetState ( $REM2S, $GUI_ENABLE)
    GUICtrlSetData ( $REM2S,"Status: Free")
    Endif
    
    if $PREM3 Then
    GUICtrlSetState ( $REM3, $GUI_DISABLE)
    GUICtrlSetState ( $REM3S, $GUI_DISABLE)
    GUICtrlSetData ( $REM2S,"Status: Busy")
    Else
    GUICtrlSetState ( $REM3, $GUI_ENABLE)
    GUICtrlSetState ( $REM3S, $GUI_ENABLE)
    GUICtrlSetData ( $REM3S,"Status: Free")
    Endif
    
    if $PREM4 Then
    GUICtrlSetState ( $REM4, $GUI_DISABLE)
    GUICtrlSetState ( $REM4S, $GUI_DISABLE)
    GUICtrlSetData ( $REM4S,"Status: Busy")
    Else
    GUICtrlSetState ( $REM4, $GUI_ENABLE)
    GUICtrlSetState ( $REM4S, $GUI_ENABLE)
    GUICtrlSetData ( $REM4S,"Status: Free")
    Endif
    
    if $PREM5 Then
    GUICtrlSetState ( $REM5, $GUI_DISABLE)
    GUICtrlSetState ( $REM5S, $GUI_DISABLE)
    GUICtrlSetData ( $REM5S,"Status: Busy")
    Else
    GUICtrlSetState ( $REM5, $GUI_ENABLE)
    GUICtrlSetState ( $REM5S, $GUI_ENABLE)
    GUICtrlSetData ( $REM5S,"Status: Free")
    Endif
    
    Else ;IF NO NETWORK
    Call("NoNetwork")

EndIf

Until $msg= $GUI_EVENT_CLOSE
#endregion Do Until Close Statment
#region Start Listening Function
Func StartListening()
    
        if $REM1R = $Gui_UnChecked AND $REM2R = $Gui_UnChecked  AND $REM3R = $Gui_UnChecked  AND $REM4R = $Gui_UnChecked  AND $REM5R = $Gui_UnChecked Then
        GUISetState(@SW_DISABLE,$Main)
        MsgBox(0x40,"Remote Support","Please Select a Remote Assistance Channel")
        GUISetState(@SW_ENABLE,$Main)
        EndIf

        if $REM1R = $Gui_Checked Then
        GUISetState(@SW_DISABLE,$Main)
        $SSR1 = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
        GUICtrlCreateLabel("Configuring Remote Assistance 1",20,15,180,40)
        GUISetState(@SW_SHOW)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" source=static addr='&$REM1CONFIG&' mask='&$MASKCONFIG)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" gateway='&$Gateway&' gwmetric=0')
        _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" source=static addr='&$DNS1CONFIG)
        _RunDos('netsh interface ip add dns name = "'&$NETCONFIG&'" addr ='&$DNS2CONFIG)
                    
        Run('"C:\Program Files\Advantig\DualDesk Viewer\Viewer.exe" -preset 4 -dotcursor -nowarnings -logfile DualDesk.log -listen 433')
        GUIDelete($SSR1)
            
        GUISetState(@SW_ENABLE,$Main)
        Endif

        if $REM2R = $Gui_Checked Then
        GUISetState(@SW_DISABLE,$Main)
        $SSR2 = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
        GUICtrlCreateLabel("Configuring Remote Assistance 2",20,15,180,40)
        GUISetState(@SW_SHOW)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" source=static addr='&$REM2CONFIG&' mask='&$MASKCONFIG)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" gateway='&$Gateway&' gwmetric=0')
        _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" source=static addr='&$DNS1CONFIG)
        _RunDos('netsh interface ip add dns name = "'&$NETCONFIG&'" addr ='&$DNS2CONFIG)
                    
        Run('"C:\Program Files\Advantig\DualDesk Viewer\Viewer.exe" -preset 4 -dotcursor -nowarnings -logfile DualDesk.log -listen 110')
        GUIDelete($SSR2)
            
        GUISetState(@SW_ENABLE,$Main)
        Endif

        if $REM3R = $Gui_Checked Then
        GUISetState(@SW_DISABLE,$Main)
        $SSR3 = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
        GUICtrlCreateLabel("Configuring Remote Assistance 3",20,15,180,40)
        GUISetState(@SW_SHOW)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" source=static addr='&$REM3CONFIG&' mask='&$MASKCONFIG)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" gateway='&$Gateway&' gwmetric=0')
        _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" source=static addr='&$DNS1CONFIG)
        _RunDos('netsh interface ip add dns name = "'&$NETCONFIG&'" addr ='&$DNS2CONFIG)
                    
        Run('"C:\Program Files\Advantig\DualDesk Viewer\Viewer.exe" -preset 4 -dotcursor -nowarnings -logfile DualDesk.log -listen 443')
        GUIDelete($SSR3)
            
        GUISetState(@SW_ENABLE,$Main)
        Endif

        if $REM4R = $Gui_Checked Then
        GUISetState(@SW_DISABLE,$Main)
        $SSR4 = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
        GUICtrlCreateLabel("Configuring Remote Assistance 4",20,15,180,40)
        GUISetState(@SW_SHOW)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" source=static addr='&$REM4CONFIG&' mask='&$MASKCONFIG)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" gateway='&$Gateway&' gwmetric=0')
        _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" source=static addr='&$DNS1CONFIG)
        _RunDos('netsh interface ip add dns name = "'&$NETCONFIG&'" addr ='&$DNS2CONFIG)
                    
        Run('"C:\Program Files\Advantig\DualDesk Viewer\Viewer.exe" -preset 4 -dotcursor -nowarnings -logfile DualDesk.log -listen 143')
        GUIDelete($SSR4)
            
        GUISetState(@SW_ENABLE,$Main)
        Endif

        if $REM5R = $Gui_Checked Then
        GUISetState(@SW_DISABLE,$Main)
        $SSR5 = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
        GUICtrlCreateLabel("Configuring Remote Assistance 5",20,15,180,40)
        GUISetState(@SW_SHOW)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" source=static addr='&$REM5CONFIG&' mask='&$MASKCONFIG)
        _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" gateway='&$Gateway&' gwmetric=0')
        _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" source=static addr='&$DNS1CONFIG)
        _RunDos('netsh interface ip add dns name = "'&$NETCONFIG&'" addr ='&$DNS2CONFIG)
                    
        Run('"C:\Program Files\Advantig\DualDesk Viewer\Viewer.exe" -preset 4 -dotcursor -nowarnings -logfile DualDesk.log -listen 119')
        GUIDelete($SSR5)
            
        GUISetState(@SW_ENABLE,$Main)
        Endif

EndFunc
#endregion Start Listening Function

#region Stop Listening Function
Func Stop()
    GUISetState(@SW_DISABLE,$Main)
    $SSSTOP = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
    GUISetState(@SW_SHOW,$SSSTOP)
    GUICtrlCreateLabel("Stopping Remote Assistance Software",5,15,190,40)
    
    ProcessClose("viewer.exe")
    _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" dhcp')
    _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" dhcp')
    GUIDelete($SSSTOP)
    
    GUISetState(@SW_ENABLE,$Main)
EndFunc
#endregion Stop Listening Function
#region Other Functions
Func Help()
        _Rundos('"Help File.chm"')
EndFunc
#endregion Other Functions
#region No Network Function
Func NoNetwork()
    GUISetState(@SW_DISABLE&@SW_RESTORE ,$Main)
    
    GUICtrlSetState ( $REM1, $GUI_DISABLE)
    GUICtrlSetData ( $REM1S,"Status: Unknown")
    GUICtrlSetState ( $REM1S, $GUI_DISABLE)
    
    GUICtrlSetState ( $REM2, $GUI_DISABLE)
    GUICtrlSetData ( $REM2S,"Status: Unknown")
    GUICtrlSetState ( $REM2S, $GUI_DISABLE)
    
    GUICtrlSetState ( $REM3, $GUI_DISABLE)
    GUICtrlSetData ( $REM3S,"Status: Unknown")
    GUICtrlSetState ( $REM3S, $GUI_DISABLE)
    
    GUICtrlSetState ( $REM4, $GUI_DISABLE)
    GUICtrlSetData ( $REM4S,"Status: Unknown")
    GUICtrlSetState ( $REM4S, $GUI_DISABLE)
    
    GUICtrlSetState ( $REM5, $GUI_DISABLE)
    GUICtrlSetData ( $REM5S,"Status: Unknown")
    GUICtrlSetState ( $REM5S, $GUI_DISABLE)
    
        $Setupsub = GUICreate("Please Wait...",200,90,-1,-1,"",$WS_EX_TOOLWINDOW)
        GUISetState(@SW_SHOW&@SW_RESTORE ,$Setupsub)
                    
        GUICtrlCreateLabel("Making Network Connection",30,15,180,20)
        $Cancel = GUICtrlCreateButton("Cancel",50,35,100,20)
    
        Do 
        $msg= GUIGetMsg()
        $pres=ping($gateway,250)
    
        Select 
        Case $msg = $Cancel
        EXIT
        Exitloop

        Case $pres>"0"
        GUIDelete($setupsub)
        Exitloop
        ENdselect
        Until $pres>"0"
        GUISetState(@SW_ENABLE,$Main)
EndFunc
#endregion No Network Function
#region Close Clicked Function
Func CloseClicked()
                if ProcessExists("viewer.exe") Then
                ProcessClose("viewer.exe")
                Endif
    
                GUISetState(@SW_DISABLE,$Main)
                $SSCL = GUICreate("Please Wait...",200,70,-1,-1,"",$WS_EX_TOOLWINDOW)
                GUICtrlCreateLabel("Closing Remote Remote Assistance",13,15,180,40)
                GUISetState(@SW_SHOW,$SSCL)
                ProcessClose("viewer.exe")
                _RunDos('netsh interface ip set address name="'&$NETCONFIG&'" dhcp')
                _RunDos('netsh interface ip set dns name="'&$NETCONFIG&'" dhcp')
                GUIDelete($SSCL)
                Exit
            EndFunc
Func ExitGui()
    Exit
EndFunc
#endregion Close Clisked Function

This code is in development so it may not be totally correct!

Share this post


Link to post
Share on other sites



Hi,

haven't looked through the whole code, but try this:

HotKeySet("1", "ExitGui") on top of your script to kill it. :lmao:

Don't Call yout func just write NoNetwork()

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0