Jump to content

Vpn Network Connection


Recommended Posts

Using Win XP version 2002 SP2

I have a virtual private network connection, and a shortcut to it on the desktop

I want to make a script to replace clicking on the shortcut -- for other shortcuts, it seems that just doing a RUN command on the shortcut traget will work fine. The network connection shortcut target is different, and I can't figure out how to script this. I did a search on the forum, and perhaps I was using the wrong search term but couldn't find it.

Help, please? :">

Link to comment
Share on other sites

  • 3 weeks later...

I'm not sure if anyone else has experienced this problem with VPN connections, but here goes:

Sometimes dialing our corporate VPN it seems to connect perfectly, but upon trying to communicate with any of the office networked PC's, I can't get a response from them (i.e. Ping). Disconnecting the VPN a random number of times finally returns a solid connection. I have searched the web for this issue and can't seem to find anything on it. This is the reason for this program. It uses RASDial.exe in Windows 2000 & XP to dial the connection and then checks for one of our servers by pinging it. If it responds it exits but if it doesn't, it then disconnects and tries again.

#include<guiconstants.au3>

$ini = @AppDataCommonDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk"
Dim $sel

$i = IniReadSectionNames($ini)

For $x = 1 to $i[0]
    If IniRead($ini, $i[$x], "Device", "") = "WAN Miniport (L2TP)" Then
        $sel = $sel & $i[$x] & "|"
    EndIf
Next
$sel = StringTrimRight($sel, 1)

GuiCreate("Select VPN", 200, 75)
$ent = GuiCtrlCreateCombo("", 30, 10, 140, 20)
GuiCtrlSetData($ent, $sel)
$btn_submit = GuiCtrlCreateButton("Fire It Up!", 37.5, 45, 125, 20)
GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $btn_submit
        $entry = '"' & GuiCtrlRead($ent) & '"'
        _VPNDial()
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Func _VPNDial()
$vpn_ip = IniRead(@ScriptDir & "\VPN Launcher.ini", "General", "VPN_IP", "")
$user = IniRead(@ScriptDir & "\VPN Launcher.ini", "General", "User", "")
$pw = IniRead(@ScriptDir & "\VPN Launcher.ini", "General", "Password", "")
$ping_ip = IniRead(@ScriptDir & "\VPN Launcher.ini", "General", "Ping_IP", "")
$cmd = "Rasdial.exe "
$i = 0

While 1
    $i = $i + 1
    TrayTip("Attempting Connection", "Attempting connection to " & $vpn_ip & @CRLF & _ 
                                          "Attempt #" & $i, 5)
    RunWait($cmd & " " & $entry & " " & $user & " " & $pw & " /phone:" & $vpn_ip, "", @SW_HIDE)
    $ping = Ping($ping_ip, 500)
    If $ping > 0 Then
    TrayTip("Success!", "A solid VPN connection has been made to " & $vpn_ip & @CRLF & _ 
                                 "Number of Attempts = " & $i, 5)       
        Sleep(3000)
        Exit
    Else
    TrayTip("Retrying Connection", "Retrying connection to " & $vpn_ip, 5)      
        RunWait($cmd & "/disconnect", "", @SW_HIDE)
        Sleep(3000)
        ContinueLoop
    EndIf
WEnd
EndFunc

The VPN Launcher.ini this program uses is formatted as follows:

[General]
VPN_IP=
User=
Password=
Ping_IP=

So far this program has worked for us beautifully.

Feel free to copy, enhance or change this to your liking.

Edited by sykes

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

question, if u try to make an vpn connection, does the server ping you back to see if its not a fake connection ??

if so, maby ur firewall is blocking it ?? ( i donnu much about vpn, but i do hate firewalls )

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...