Hi all,

I would like to be able to create a VBScript that when run would
automatically create the VPN Connection and then automatically launch
so that the user can then enter there username and password. Is this
possible. If so how can it be done.

Any help in this matter would be highly appreciated.

Thank you

Re: Creating a VPN Connection by Stace

Stace
Mon Mar 03 03:54:42 CST 2008

<christopher_board@yahoo.co.uk> wrote in message
news:0fbe4554-1409-42b7-9c13-b37ff9f3fe9f@59g2000hsb.googlegroups.com...
> Hi all,
>
> I would like to be able to create a VBScript that when run would
> automatically create the VPN Connection and then automatically launch
> so that the user can then enter there username and password. Is this
> possible. If so how can it be done.
>
> Any help in this matter would be highly appreciated.
>
> Thank you

I have used the following script to do this but it isn't ideal as it relies
on the SendKeys method:

' script to create a VPN network connection
' for anyones use and create a desktop shortcut
Dim objShell: Set objShell = CreateObject("Wscript.Shell")

strHost="192.168.0.1" ' ip address of VPN endpoint
strCo="My VPN" ' friendly name for the VPN connection

MsgBox "Creating VPN connection. Please click OK to continue and then do not
use your mouse or keyboard until a message appears confirming that this
process has finished.",vbOKonly + vbInformation,"Add VPN Connection"

With objShell
.Run "Control ncpa.cpl"
wscript.sleep 2000
.AppActivate "Network Connections"
wscript.sleep 1000
.SendKeys "%FN"
wscript.sleep 1000
.SendKeys "%N"
wscript.sleep 1000
.SendKeys "%ON"
wscript.sleep 1000
.SendKeys "%VN"
wscript.sleep 1000
.SendKeys "%A" & strCo & "%N"
wscript.sleep 1000
.SendKeys "%DN"
wscript.sleep 1000
.SendKeys "%H" & strHost & "%N"
wscript.sleep 1000
.SendKeys "%AN"
wscript.sleep 1000
.SendKeys "%S"
wscript.sleep 1000
.SendKeys "{TAB}{TAB}~"
wscript.sleep 1000
.AppActivate "Connect " + strCo
.SendKeys "%{F4}"
End With

MsgBox "A VPN connection has been created and a shortcut placed on your
desktop. It is OK to use your mouse and keyboard again now.",vbOKonly +
vbInformation,"Add VPN Connection"

Set objShell=Nothing

HTH,
Stace.