Automatically make a VPN w/ script?

Dell Latitude
November 5, 2007 at 13:16:17
Specs: Windows XP Professional, PIII 650 / 256MB
Hi, I was wondering if it's possible to create a VPN connection in the same way as one would do by going to Network Connections>Create a new Connection by using a script? For example, I would create a VBscript, and after it has run, go to Network Connections and find a brand new VPN connection with the same settings as what I specified in the script. Is this possible? If so, where could I find information on how to do this? Thanks for your help.

Jesus can change your life for the better!!


See More: Automatically make a VPN w/ script?

Report •


#1
November 5, 2007 at 14:03:52
AutoIT Script would be what your looking for.

A script such as what you want would need some Send(), WinWait(), and ControlClick() or MouseClick() functions so take a look at those.

"Computer security." — Oxymoron


Report •

#2
November 5, 2007 at 15:07:38
tonysathre,

This is EXACTLY what I need! Thank you sir!! I can't thank you enough for sending me the link to this application.
Jesus can change your life for the better!!


Report •

#3
November 5, 2007 at 19:23:21
I got my script exactly how I want it. It works great. Wow you can sure do alot with AutoIT! Thanks again!

Jesus can change your life for the better!!


Report •

Related Solutions

#4
November 5, 2007 at 22:30:24
Wow, that was fast. Would you mind posting the code? Maybe I could find a use for it.

Thanks,

Tony


Report •

#5
November 6, 2007 at 08:49:44
Tony,

I'd be glad to post it. It works best when your screen resolution is set to 1024 x 768 because of the mouse clicks. Sometime I could do it with just keyboard and no mouse.

Well, here goes:

; Set up a VPN Server on XP Pro Automatically
;
; Created by RutherSoft Software

DIM $mb

; Ask the user if he/she wants to setup the vpn
$mb = MsgBox(36,"Incoming Connection (VPN) Automatic Setup Script","This script will set up this computer to accept incoming VPN connections. Before running this script, make sure your screen resolution is 1024 x 768. Are you sure you want to run this script?")
If $mb == 6 Then ; if the user clicked yes, do it!
MouseClick("Left",33,750) ; click the Start button
MouseClick("Left",304,560) ; click Connect To...
MouseClick("Left",498,610) ; Click Show All Connections to bring up Network Connections
WinWaitActive("Network Connections") ; wait till the Network Connections window appears
; Since the network connections window is sometimes placed at different places on the
; screen we use the menu to click Create a New Connection.
Send("{ALT}f{DOWN}{DOWN}{DOWN}") ; Goto File and highlight Create a New Connection
Send("{ENTER}") ; press enter to load the wizard
WinWaitActive("New Connection Wizard") ; wait till the wizard appears
Sleep(2000) ; wait for the Next button to become enabled
MouseClick("Left",630,550) ; click Next
MouseClick("Left",313,433) ; Click the "Set Up an Advanced Connection" radio button
MouseClick("Left",630,550) ; Click Next
MouseClick("Left",630,550) ; Click Next on this window because "Accept Incoming Connections" is already checked
Sleep(8000) ; The computer is saving settings, give it plenty of time
MouseClick("Left",630,550) ; Click Next because there aren't any options we need here
Sleep(10) ; Some older systems pause here a little, make room for that
MouseClick("Left",328,400) ; Click the "Allow Incoming Connections" checkbox
MouseClick("Left",630,550) ; Click Next
; The following code automatically selects the permissions of who can log on remotely.
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}") ; Bring the listview control into keyboard focus
; check everything except the 'Guest' account because it gives any hacker complete access to the computer
Send("{+}{DOWN}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}{DOWN}{+}")
MouseClick("Left",630,550) ; click Next
Sleep(2000) ; a slight pause here, make up for it
MouseClick("Left",630,550) ; click Next here because there aren't any settings to change
Sleep(2000) ; slight pause here
MouseClick("Left",630,550) ; click Finish to exit the Wizard
Sleep(2000) ; give the wizard time enough to close
MsgBox(64,"VPN Script","The script is now finished.") ; tell the user we're done!

EndIf

; the end

Jesus can change your life for the better!!


Report •

#6
November 6, 2007 at 10:10:21
Here's how to create the VPN Client:

; Set up a VPN Client on Windows XP
;
; by RutherSoft Software

DIM $m1
DIM $m2
DIM $ip
DIM $conname
DIM $nclv

; ask the user if he/she wants to set up a VPN Client
$m1 = MsgBox(36,"Automatic XP Pro VPN Client Configuration","Do you want to automatically set up a Windows XP Pro VPN Client on this computer? If so, make sure your screen resolution is 1024 x 768.")
if $m1 == 6 Then ; if the user clicked Yes, do it!
; prompt for a connection name
$conname = InputBox("Please Enter Connection Name","Please enter a name for this connection, like Office for example.","Connection 1")
if $conname == 1 Then ; if the user clicked Cancel,
Exit ; Exit
EndIf
; prompt for the VPN Server's IP Address
$ip = InputBox("Please Enter Server's External IP Address","Please enter the Server's External IP. This can be attained by going to http://www.whatismyip.com on the Server.")
if $ip == 1 Then ; if the user clicked Cancel,
Exit ; Exit
EndIf
; ask the user if he/she wants a shortcut on the desktop; the user's answer will be used later
$m2 = MsgBox(36,"Add Shortcut to Desktop?","Do you want a shortcut to the VPN to be placed on the desktop when finished?")

MouseClick("Left",33,750) ; click the start button
MouseClick("Left",304,560) ; click "Connect To..."
Send("{UP}{ENTER}") ; highlight "Show All Connections" and press enter to pull up the Network Connections window
WinWaitActive("Network Connections") ; wait for the window to appear
Send("{ALT}f{DOWN}{DOWN}{DOWN}") ; Go to File and highlight "Create a new connection"
Send("{ENTER}") ; press enter to pull up the wizard
WinWaitActive("New Connection Wizard") ; wait for the wizard to appear
Sleep(2000) ; wait for the Next button to become enabled
MouseClick("Left",630,550) ; click Next
MouseClick("Left",515,342) ; click the "Connect to the network at my workplace" radiobutton
MouseClick("Left",630,550) ; click Next
MouseClick("Left",513,374) ; Click the "Virtual Private Connection" radiobutton
MouseClick("Left",630,550) ; click Next
MouseClick("Left",520,350) ; click the "Company Name" textbox to ensure it has the focus
Send($conname) ; type in the connection name that was entered
MouseClick("Left",630,550) ; Click Next
MouseClick("Left",511,339) ; Click the "Do not automatically dial this connection" radiobutton
MouseClick("Left",630,550) ; Click Next
MouseClick("Left",429,351) ; click the "Hostname or IP Address" textbox to ensure it has the focus
Send($ip) ; type the entered IP
MouseClick("Left",630,550) ; click Next
if $m2 == 6 Then ; if the user wanted a desktop shortcut
MouseClick("Left",551,454) ; click the "Add a shortcut to this connection on my desktop" checkbox
EndIf
ControlClick("New Connection Wizard","New Connection Wizard",12325) ; click Finish to exit the wizard
Sleep(2500) ; wait for the "Connect..." window to appear
MouseClick("Left",486,553) ; click Cancel on it because there's another setting we have to change first
$nclv = ControlListView("Network Connections","Network Connections",1,"FindItem",$conname) ; find the connection in the listview
; on the Network Connections window
ControlListView("Network Connections","Network Connections",1,"Select",$nclv) ; select it
Send("{APPSKEY}") ; bring up the right-click menu
Sleep(200) ; wait for it to appear
Send("{UP}") ; push the Up key to highlight properties
Sleep(200) ; slow things down a tad
Send("{ENTER}") ; push enter to bring up the Properties dialog
Sleep(5000) ; wait for it to appear
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{RIGHT}{RIGHT}{RIGHT}") ; go to the "Networking" tab
Sleep(1500) ; slow it down a tad
Send("{TAB}{TAB}{ENTER}") ; bring the "Settings" button into keyboard focus and push enter to bring up the "PPP Settings" window
Sleep(1500) ; wait for it to appear
Send("{DOWN}{DOWN}{+}{ENTER}") ; Check the "Negotiate Multi-Link for Single-Link Connections" checkbox and close the "PPP Settings" window
Sleep(1500) ; slow it down a little
Send("{TAB}{ENTER}") ; Bring the OK button on the Properties window into keyboard focus and close the window
Sleep(1500) ; give it some time to close
MsgBox(64,"Finished","The VPN Client is now setup.") ; tell the user it's done!
EndIf

; the end!


Jesus can change your life for the better!!


Report •


Ask Question