Jump to content
Sign in to follow this  
iamtheky

VPN_tool

Recommended Posts

iamtheky

I'm always amazed at how the simplest scripts become the most useful, or most used.  If you have folk who VPN and have to traverse machines, you should build them one of these.  Its way too easy, and they will want to service you right there in the office.  Some basic examples of mapping a drive, file transfer, RDP, and bringing up a device in the browser are provided.   

It tries to connect the VPN (via the Cisco VPN client) on execution (line 37)...so you will want to fill out the commands with proper IPs and credentials first. 

We are all old in my shop so SkellySouls  classic Steam flavored GUI gave it some extra weight.  

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>


HotKeySet("{ESC}", "_Exit")
$Width = 500
$Height = 205
Global $ButtonGetAW , $ButtonPutAW , $ButtonGetNAS , $ButtonPutNAS , $ButtonRDPAlien , $ButtonNASGUI
_Steam("SOC TOOL - " & @ComputerName, $Width, $Height, Default, Default)
While 1
    Sleep(1000)
WEnd
Func _Steam($sTitle, $sWidth, $sHeight, $sX, $sY)
;;; Steam Window Start ;;;
$Steam_Win = GUICreate($sTitle, $sWidth, $sHeight, $sX, $sY , $WS_POPUP, $WS_EX_TOOLWINDOW)
GUISetFont(8, 600, 0, "Tahoma")
GUISetBkColor(0x464646)
;;; Steam Window End ;;;
;;; Steam Title Bar Start ;;;
$Bar = GUICtrlCreateLabel($sTitle , 0 , 0 , $sWidth - 20, 20 , $SS_NOTIFY , $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont($Bar, 10, 600, 0, "Tahoma") ; Bold
GUICtrlSetColor($Bar , 0xD8DED3)
GUICtrlSetBkColor($Bar , 0x5A6A50)
;;; Steam Title Bar End ;;;
;;; Steam Title Exit Start ;;;
$Exit = GUICtrlCreateLabel("X" , $sWidth - 20 , 0 , 20 , 20 , $SS_CENTER)
GUICtrlSetFont($Exit, 10, 800, 0, "Tahoma") ; Bold
GUICtrlSetColor($Exit , 0xD8DED3)
GUICtrlSetBkColor($Exit, 0x5A6A50)
;;; Steam Title Exit End ;;;
_Steam_Extension($Width, $Height) ; Create Full GUI
GUISetState(@SW_SHOW)


runwait('cmd /c ' & '"' & 'C:\program files (x86)\Cisco Systems\VPN Client\vpnclient.exe' & '"' & ' connect CONNECTIONNAME user USERNAME pwd PASSWORD')



While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Exit
            runwait('cmd /c ' & '"' & 'C:\program files (x86)\Cisco Systems\VPN Client\vpnclient.exe' & '"' & ' disconnect')
            Exit
        Case $ButtonPutAW
            _Copy2Alien()
        Case $ButtonGetAW
            _Alien2me()
        Case $ButtonPutNAS
            _CopytoNAS()
        Case $ButtonGetNAS
            _NAStoMe()
        Case $ButtonRDPAlien
            _RDPalien()
        Case $ButtonNASGUI
            _NASGUI()
    EndSwitch
WEnd
EndFunc
Func _Steam_Extension($eWidth, $eHeight)
$Steam_Arm_X = 200 ; This adjusts the Arms Width
$Steam_Arm_Y = 20 ; This really shouldn't be played with...
;;; Steam Arm Start ;;;
$Arm = GUICtrlCreateGraphic($Steam_Arm_X, $Steam_Arm_Y, $eWidth - $Steam_Arm_X, $eHeight - $Steam_Arm_Y)
GUICtrlSetBkColor($Arm, 0x494E48)
GUICtrlSetState($Arm, $GUI_DISABLE)
;;; Steam Arm End ;;;
;;; Steam Test Buttons ;;;

  $ButtonPutAW = GUICtrlCreateButton("Copy2Alien", 10, 30, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonGetAW = GUICtrlCreateButton("Alien2me", 10, 60, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonPutNAS = GUICtrlCreateButton("CopyToNAS", 10, 90, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonGetNAS = GUICtrlCreateButton("NAStoMe", 10, 120, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonNASGUI = GUICtrlCreateButton("NAS GUI", 10, 150, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonRDPAlien = GUICtrlCreateButton("rdp2alien", 10, 180, $Steam_Arm_X - $Steam_Arm_Y, 20)
;;; Steam Test Buttons ;;;
;;; Steam Border Start ;;;
$Border = GUICtrlCreateGraphic($Steam_Arm_X + 10, 30, $eWidth - $Steam_Arm_X - $Steam_Arm_Y, $eHeight - $Steam_Arm_Y - $Steam_Arm_Y)
$Header = GUICtrlCreateGraphic($Steam_Arm_X + 10, 30, $eWidth - $Steam_Arm_X - $Steam_Arm_Y, 20)
GUICtrlSetColor($Border, 0x696A65)
GUICtrlSetColor($Header, 0x696A65)
GUICtrlSetState($Border, $GUI_DISABLE)
GUICtrlSetState($Header, $GUI_DISABLE)
;;; Steam Border End ;;;
;;; Steam Sample Text Start ;;;
$Text = GUICtrlCreateLabel("Maybe an info area?", 220, 35, 200, 20)
GUICtrlSetColor($Text, 0xC3B54C)
GUICtrlSetBkColor($Text, $GUI_BKCOLOR_TRANSPARENT)
;;; Steam Sample Text End ;;;
;;; Steam Sample Control ;;;
GUICtrlCreateEdit("This is a placeholder." , 223, 60, 255, 118) ;;; 220x60 is where controls should start.
;;; Steam Sample Control ;;;
EndFunc
Func _Exit()
Exit
EndFunc

Func _Alien2me()
    $file = FileOpenDialog("Alien2me" , "\\172.16.10.11\images" , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy "  & '"' & $file & '"' & " " & '"' & @ScriptDir & "\" & $afile[$afile[0]]  & '"' & "* /Y")
EndFunc

Func _Copy2Alien()
    $file = FileOpenDialog("Copy2Alien" , @ScriptDir , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy " & '"' & $file & '"' & " " & '"' & "\\172.16.70.111\images\" & $afile[$afile[0]] & '"' & "* /Y")
EndFunc

Func _CopytoNAS()
    runwait("net use Z: \\172.16.10.8\Public\SHARE\Tools PASSWORD /user:admin")
    $file = FileOpenDialog("toNAS" , @ScriptDir , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy " & '"' & $file & '"' & " " & '"' & "z:\" & $afile[$afile[0]] & '"' & "* /Y")
EndFunc

Func _NAStoMe()
    runwait("net use Z: \\172.16.10.8\Public\SHARE\Tools PASSWORD /user:admin")
    $file = FileOpenDialog("NAS2me" , "Z:\" , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy " & '"' & $file & '"' & " " & '"' & @ScriptDir & "\" & $afile[$afile[0]] & '"' & "* /Y")
EndFunc

Func _RDPalien()
    runwait("mstsc /v:172.16.10.11")
EndFunc

Func _NASGUI()
    shellexecute("http://172.16.10.8")
EndFunc
Edited by boththose
  • Like 1

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
SkellySoul

Quick little edit...I hope you don't mind. I didn't really get to test it but instead of a static IP address, I made it a variable. You can even use @IPAddress1 or _GetIP()

A few other modifications that could be added is

- Add @SW_HIDE to some of the runwaits that use cmd (unless you like the visual effect)

- Replace "C:program files (x86)" with @HomeDrive / @ProgramFilesDir

:thumbsup:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "_Exit")

$Width = 500
$Height = 205
Global $IP_Address = "172.16.10.8", $ButtonGetAW , $ButtonPutAW , $ButtonGetNAS , $ButtonPutNAS , $ButtonRDPAlien , $ButtonNASGUI

_Steam("SOC TOOL - " & @ComputerName, $Width, $Height, Default, Default)

Func _Steam($sTitle, $sWidth, $sHeight, $sX, $sY)
;;; Steam Window Start ;;;
$Steam_Win = GUICreate($sTitle, $sWidth, $sHeight, $sX, $sY , $WS_POPUP, $WS_EX_TOOLWINDOW)
GUISetFont(8, 600, 0, "Tahoma")
GUISetBkColor(0x464646)
;;; Steam Window End ;;;
;;; Steam Title Bar Start ;;;
$Bar = GUICtrlCreateLabel($sTitle , 0 , 0 , $sWidth - 20, 20 , $SS_NOTIFY , $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont($Bar, 10, 600, 0, "Tahoma") ; Bold
GUICtrlSetColor($Bar , 0xD8DED3)
GUICtrlSetBkColor($Bar , 0x5A6A50)
;;; Steam Title Bar End ;;;
;;; Steam Title Exit Start ;;;
$Exit = GUICtrlCreateLabel("X" , $sWidth - 20 , 0 , 20 , 20 , $SS_CENTER)
GUICtrlSetFont($Exit, 10, 800, 0, "Tahoma") ; Bold
GUICtrlSetColor($Exit , 0xD8DED3)
GUICtrlSetBkColor($Exit, 0x5A6A50)
;;; Steam Title Exit End ;;;
_Steam_Extension($Width, $Height) ; Create Full GUI
GUISetState(@SW_SHOW)

runwait('cmd /c ' & '"' & 'C:\program files (x86)\Cisco Systems\VPN Client\vpnclient.exe' & '"' & ' connect CONNECTIONNAME user USERNAME pwd PASSWORD')

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Exit
            runwait('cmd /c ' & '"' & 'C:\program files (x86)\Cisco Systems\VPN Client\vpnclient.exe' & '"' & ' disconnect')
            Exit
        Case $ButtonPutAW
            _Copy2Alien()
        Case $ButtonGetAW
            _Alien2me()
        Case $ButtonPutNAS
            _CopytoNAS()
        Case $ButtonGetNAS
            _NAStoMe()
        Case $ButtonRDPAlien
            _RDPalien()
        Case $ButtonNASGUI
            _NASGUI()
    EndSwitch
WEnd
EndFunc

Func _Steam_Extension($eWidth, $eHeight)
$Steam_Arm_X = 200 ; This adjusts the Arms Width
$Steam_Arm_Y = 20 ; This really shouldn't be played with...
;;; Steam Arm Start ;;;
$Arm = GUICtrlCreateGraphic($Steam_Arm_X, $Steam_Arm_Y, $eWidth - $Steam_Arm_X, $eHeight - $Steam_Arm_Y)
GUICtrlSetBkColor($Arm, 0x494E48)
GUICtrlSetState($Arm, $GUI_DISABLE)
;;; Steam Arm End ;;;
;;; Steam Test Buttons ;;;

  $ButtonPutAW = GUICtrlCreateButton("Copy2Alien", 10, 30, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonGetAW = GUICtrlCreateButton("Alien2me", 10, 60, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonPutNAS = GUICtrlCreateButton("CopyToNAS", 10, 90, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonGetNAS = GUICtrlCreateButton("NAStoMe", 10, 120, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonNASGUI = GUICtrlCreateButton("NAS GUI", 10, 150, $Steam_Arm_X - $Steam_Arm_Y, 20)
  $ButtonRDPAlien = GUICtrlCreateButton("rdp2alien", 10, 180, $Steam_Arm_X - $Steam_Arm_Y, 20)
;;; Steam Test Buttons ;;;
;;; Steam Border Start ;;;
$Border = GUICtrlCreateGraphic($Steam_Arm_X + 10, 30, $eWidth - $Steam_Arm_X - $Steam_Arm_Y, $eHeight - $Steam_Arm_Y - $Steam_Arm_Y)
$Header = GUICtrlCreateGraphic($Steam_Arm_X + 10, 30, $eWidth - $Steam_Arm_X - $Steam_Arm_Y, 20)
GUICtrlSetColor($Border, 0x696A65)
GUICtrlSetColor($Header, 0x696A65)
GUICtrlSetState($Border, $GUI_DISABLE)
GUICtrlSetState($Header, $GUI_DISABLE)
;;; Steam Border End ;;;
;;; Steam Sample Text Start ;;;
$Text = GUICtrlCreateLabel("Maybe an info area?", 220, 35, 200, 20)
GUICtrlSetColor($Text, 0xC3B54C)
GUICtrlSetBkColor($Text, $GUI_BKCOLOR_TRANSPARENT)
;;; Steam Sample Text End ;;;
;;; Steam Sample Control ;;;
GUICtrlCreateEdit("This is a placeholder." , 223, 60, 255, 118) ;;; 220x60 is where controls should start.
;;; Steam Sample Control ;;;
EndFunc

Func _Alien2me()
    $file = FileOpenDialog("Alien2me" , "\\" & $IP_Address & "\images" , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy "  & '"' & $file & '"' & " " & '"' & @ScriptDir & "\" & $afile[$afile[0]]  & '"' & "* /Y")
EndFunc

Func _Copy2Alien()
    $file = FileOpenDialog("Copy2Alien" , @ScriptDir , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy " & '"' & $file & '"' & " " & '"' & "\\" & $IP_Address & "\images\" & $afile[$afile[0]] & '"' & "* /Y")
EndFunc

Func _CopytoNAS()
    runwait("net use Z: \\" & $IP_Address & "\Public\SHARE\Tools PASSWORD /user:admin")
    $file = FileOpenDialog("toNAS" , @ScriptDir , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy " & '"' & $file & '"' & " " & '"' & "z:\" & $afile[$afile[0]] & '"' & "* /Y")
EndFunc

Func _NAStoMe()
    runwait("net use Z: \\" & $IP_Address & "\Public\SHARE\Tools PASSWORD /user:admin")
    $file = FileOpenDialog("NAS2me" , "Z:\" , "ALL (*.*)" , 1)
    $afile = StringSplit($file , "\")
    Runwait ("cmd /c xcopy " & '"' & $file & '"' & " " & '"' & @ScriptDir & "\" & $afile[$afile[0]] & '"' & "* /Y")
EndFunc

Func _RDPalien()
    runwait("mstsc /v:" & $IP_Address)
EndFunc

Func _NASGUI()
    shellexecute("http://" & $IP_Address)
EndFunc

Func _Exit()
    Exit
EndFunc

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  

×