Sign in to follow this  
Followers 0
lookfar

VPN connection

1 post in this topic

I have a few users outside the network that need to run a locally installed sql client but need to connect to one of the network servers with the sql database. what I have done is attempt to automate the process to make it as seamless as possible for the end user. The script as is works fine but it means I have to touch the PC's to setup the initial VPN connection:

Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)
$cmd = "c:\windows\notepad.exe"

TrayTip("Connecting to Sql Server", "one moment...", 1,1)
Sleep(2000)
Runwait(@ComSpec & " /c " & "rasdial MyVPNConnection myusername mypassword", @WindowsDir & "\System32",@SW_HIDE)

Sleep(2000)
Runwait($cmd)
; map drives or whatever..

TrayTip("Sql Session", "Finished", 1, 1)
Sleep(1000)
Run(@ComSpec & " /c " & "rasdial /disconnect",@WindowsDir & "\System32", @SW_HIDE); Disconnect

I replaced the original sql client app with notepad.exe for testing purposes, but drives may be mapped etc at that point or access to any of the resources on the network by IP address's (no netbios)

here is what I have to setup the initial VPN connection:

Send("#r") 
ClipPut("rasphone")
Send("^v")
WinWaitActive ( "Run", "" , 100 )
Send("{enter}")
WinWaitActive ( "Network Connections", "" , 100 )
send("!N")
WinWaitActive ( "New Connection Wizard", "" , 100)
Send("!t")
Send("!N")
;Sleep(300)
Send("!D")
Send("!N")
;Sleep(300)
ClipPut("192.168.1.100")
Send("^v")
Send("!N")
;Sleep(300)
ClipPut("MyVPNConnection")
Send("^v")
Send("{enter}")
ControlClick("Network Connections", "", "", "center")
Send("{Esc}")

Question is: how can I determine if the VPN connection already exists? and if not to run the above and just carry on and connect.

Is there an easier or more graceful way to create the VPN connection without running the wizard (it flashes dialogs) perhaps using rasphone -a (add entry) ?

any ideas?

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