Automatic VPN connection creation under Windows 7

Source: Internet
Author: User
Tags exit goto reset sleep

After Windows XP VPN is automatically created and configured to connect, we also need to make an introduction to VPN Autoconfiguration under Windows 7, since many organizations are actually already starting to use a large volume of Windows 7. And many users are moving toward Windows 7, so how do you make windows 7 users a good user experience? How to simplify the VPN creation of these users is also what we need to consider, and continue with the previous content I'll share my configuration under Windows 7.

The registry import was also implemented in the Windows 7 VPN batch script when the Sstp_vpn mode was completed in Tmg-vpn, and of course, we said that you might need to import this registry key only if you have installed and configured Sstp-vpn in your enterprise. If you only need to complete the automatic creation of the VPN configuration, you can also not add this part of the batch script content.

OK, next, let's take a look at how to automate the creation of VPN connections under Windows 7.

@echo Off & Color 5a

Echo:::::::::::::::::.:::::::::::::::::::::::::::::::::::;:::::::;:::::;:::::::;:- ::::::::::::

echo Windows 7_vpn Connection Configuration

Echo:::::::::::::::::.:::::::::::::::::::::::::::::::::::;:::::::;:::::;:::::::;:- ::::::::::::

In the Echo configuration process, do not do anything to ensure that the configuration is completed successfully!

Echo.

Echo. I wish you a happy and smooth work!

Echo.

echo Confirm installation configuration VPN Press any key to continue!

Pause

Cls

@echo off

Echo is checking to see if VPN1.Test.com exists, please wait a moment ...

@echo off

choice/t 5/d Y/n>nul

Find "VPN1. test.com "%userprofile%\appdata\roaming\microsoft\network\connections\pbk\rasphone.pbk && goto:vpn2. test.com | | Goto:addVPN1.Test.com

: VPN2. test.com

@echo off

Cls

Echo VPN1. Test.com already exists or created to complete!

Cls

Echo is checking to see if VPN2.Test.com exists, please wait a moment ...

@echo off

choice/t 5/d Y/n>nul

Find "VPN2. test.com "%userprofile%\appdata\roaming\microsoft\network\connections\pbk\rasphone.pbk && goto:vpn3. test.com | | Goto:addVPN2.Test.com

: VPN3. test.com

@echo off

Cls

Echo VPN2. Test.com already exists or created to complete!

Cls

Echo is checking to see if VPN3.Test.com exists, please wait a moment ...

@echo off

choice/t 5/d Y/n>nul

Find "VPN3. test.com "%userprofile%\appdata\roaming\microsoft\network\connections\pbk\rasphone.pbk && Goto:no | | Goto:addVPN3.Test.com

Pause

: addVPN1.Test.com

@echo off

Echo is creating a PEKD1.Vancl.cn connection, please wait ...

echo Set WshShell = CreateObject ("Wscript.Shell") > Test_vpn. VBS

echo wshshell.run "Rasphone-a" >>test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+w" >>test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+i" >>test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

Echo Wshshell.sendkeys "VPN1. Test.com ">>test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+e" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

Echo Wshshell.sendkeys "VPN1. Test.com ">>test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+n" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+c" >>test_vpn. VBS

Start Test_vpn. VBS

Cls

Echo is completing the VPN1.Test.com_VPN connection configuration, please wait a moment!

Ping 127.0.0.1-n 10>nul

Cls

Echo VPN1. test.com connection creation completes, will create VPN1.Test.com desktop shortcut for you, please wait a moment ...

Ping 127.0.0.1-n 10>nul

(Echo Set Ws=createobject ("Wscript.Shell" ^)

echo Ws.run "cmd/c ncpa.cpl", 0

echo Wscript.Sleep 1000

Echo Ws.sendkeys "{f5}"

echo Wscript.Sleep 1000

Echo Ws.sendkeys "VPN1. Test.com "

Echo Wscript.Sleep 500

echo Ws.sendkeys "%%{f}"

Echo Wscript.Sleep 500

Echo Ws.sendkeys "{s}"

Echo Wscript.Sleep 300

Echo Ws.sendkeys "{y}"

Echo Wscript.Sleep 300

echo Ws.sendkeys "%%{f4}") >%temp%\test_vpn.vbs

Start/wait%temp%\test_vpn.vbs

Cls

Echo VPN1. test.com Desktop shortcut Creation complete, will be configured for you VPN2.Test.com connection, please wait a moment ...

Ping 127.0.0.1-n 10>nul

GOTO:VPN2. test.com

: addVPN2.Test.com

Echo is creating a PEKD2.Vancl.cn connection, please wait ...

echo Set WshShell = CreateObject ("Wscript.Shell") > Test_vpn. VBS

echo wshshell.run "Rasphone-a" >>test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+w" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+i" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

Echo Wshshell.sendkeys "VPN2. Test.com ">> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+e" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

Echo Wshshell.sendkeys "VPN2. Test.com ">> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+n" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+c" >> Test_vpn. VBS

Start Test_vpn. VBS

Cls

Echo is completing the VPN2.Test.com_VPN connection configuration, please wait a moment!

Ping 127.0.0.1-n 10>nul

Cls

Echo VPN2. test.com connection creation completes, will create VPN2.Test.com desktop shortcut for you, please wait a moment ...

Ping 127.0.0.1-n 10>nul

(Echo Set Ws=createobject ("Wscript.Shell" ^)

echo Ws.run "cmd/c ncpa.cpl", 0

echo Wscript.Sleep 1000

Echo Ws.sendkeys "{f5}"

echo Wscript.Sleep 1000

Echo Ws.sendkeys "VPN2. Test.com "

Echo Wscript.Sleep 500

echo Ws.sendkeys "%%{f}"

Echo Wscript.Sleep 500

Echo Ws.sendkeys "{s}"

Echo Wscript.Sleep 300

Echo Ws.sendkeys "{y}"

Echo Wscript.Sleep 300

echo Ws.sendkeys "%%{f4}") >%temp%\test_vpn.vbs

Start/wait%temp%\test_vpn.vbs

Cls

Echo VPN2. test.com Desktop shortcut Creation complete, will be configured for you VPN3.Test.com connection, please wait a moment ...

Ping 127.0.0.1-n 10>nul

Goto:vpn3. test.com

: addVPN3.Test.com

Echo is creating a VPN3.Test.com connection, please wait ...

echo Set WshShell = CreateObject ("Wscript.Shell") > Test_vpn. VBS

echo wshshell.run "Rasphone-a" >>test_vpn. VBS

Echo Wscript.Sleep 500>>test_vpn. VBS

echo Wshshell.sendkeys "%%+w" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+i" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

Echo Wshshell.sendkeys "VPN3. Test.com ">> Test_vpn. VBS

Echo Wscript.Sleep 100>>test_vpn. VBS

echo Wshshell.sendkeys "%%+e" >> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

Echo Wshshell.sendkeys "VPN3. Test.com ">> Test_vpn. VBS

Echo Wscript.Sleep >>test_vpn. VBS

echo Wshshell.sendkeys "%%+n" >> Test_vpn. VBS

Echo Wscript.Sleep 100>>test_vpn. VBS

echo Wshshell.sendkeys "%%+c" >> Test_vpn. VBS

Start Test_vpn. VBS

Cls

Echo is completing the VPN3.Test.com_VPN connection configuration, please wait a moment!

Ping 127.0.0.1-n 10>nul

Cls

Echo VPN3. test.com connection creation completes, will create VPN3.Test.com desktop shortcut for you, please wait a moment ...

Ping 127.0.0.1-n 10>nul

(Echo Set Ws=createobject ("Wscript.Shell" ^)

echo Ws.run "cmd/c ncpa.cpl", 0

echo Wscript.Sleep 1000

Echo Ws.sendkeys "{f5}"

echo Wscript.Sleep 1000

Echo Ws.sendkeys "VPN3. Test.com "

Echo Wscript.Sleep 500

echo Ws.sendkeys "%%{f}"

Echo Wscript.Sleep 500

Echo Ws.sendkeys "{s}"

Echo Wscript.Sleep 300

Echo Ws.sendkeys "{y}"

Echo Wscript.Sleep 300

echo Ws.sendkeys "%%{f4}") >%temp%\test_vpn.vbs

Start/wait%temp%\test_vpn.vbs

Cls

Echo VPN3. test.com Desktop shortcut Creation complete.

Del Test_vpn. VBS

Ping 127.0.0.1-n 10>nul

Cls

Goto:check_vpn

: Check_vpn

Echo is about to proofread the configuration VPN connection line, please ...

@echo off

choice/t 5/d y/n >nul

Echo VPN1. test.com Configuration Proofing Complete!

@echo off

choice/t 5/d Y/n>nul

Echo VPN2. test.com Configuration Proofing Complete!

@echo off

choice/t 5/d Y/n>nul

Echo VPN3. test.com Configuration Proofing Complete!

Ping 127.0.0.1-n 10>nul

Goto:creat_pbk

: creat_pbk

Echo is about to generate TEST_VPN for you. pbk Desktop Files

@echo off

choice/t 5/d Y/n>nul

for/f ' delims= '%%i in (' Set ws=wscript.createobject (' Wscript.Shell ') ') do echo%%i >>test_vpn.vbs

for/f "delims="%%i in ("Strdesktop=ws". Specialfolders ("desktop") "Do Echo%%i >>test_vpn.vbs

for/f "delims="%%i in ("Set path=ws. CreateShortcut (Strdesktop & "\test_vpn.lnk") do echo%%i>>test_vpn.vbs

for/f "delims="%%i in ("Path.targetpath="%userprofile%\appdata\roaming\microsoft\network\connections\pbk\ Rasphone.pbk "") do echo%%i >> test_vpn.vbs

for/f "delims="%%i in ("Path.save") do echo%%i>> Test_vpn.vbs

cscript Test_vpn.vbs & del Test_vpn.vbs

@echo off

choice/t 5/d Y/n>nul

Goto:import_reg

: Import_reg

Echo is about to import SSTP related registry files for you

@echo off

choice/t 5/d Y/n>nul

echo Windows Registry Editor Version 5.00 >import.reg

Echo.>>import.reg

echo [Hkey_local_machine\system\currentcontrolset\services\sstpsvc\parameters] >> Import.reg

Echo.>>import.reg

echo "Nocertrevocationcheck" =dword:00000001>>import.reg

Echo.>>import.reg

REGEDIT/S Import.reg

Del Import.reg

echo Registry Import complete!

choice/t 5/d Y/n>nul

Del Test_vpn.vbs

Echo:::::::::::::::::.:::::::::::::::::::::::::::::::::::;:::::::;:::::;:::::::;:- ::::::::::::

echo Thank you for your patience, Windows 7_vpn configuration complete

Echo Now you can use any of the configured VPN as a connection point

Echo:::::::::::::::::.:::::::::::::::::::::::::::::::::::;:::::::;:::::;:::::::;:- ::::::::::::

echo Thank you for your use!

@echo off

set/p reset= Press the Y key to restart the computer Application registry key, press any key to exit later on its own reboot:

If%reset%==y (goto:reboot) Else (goto:noreboot)

: Reboot

SHUTDOWN/R/T 0

: noreboot

echo Thank you for your use!

choice/t 2/d Y/n>nul

Exit

: No

Cls

echo off

VPN1.Test.com and VPN2 already exist in the echo system. test.com and VPN3.Test.com connection, press any key to exit & Pause

This article is from the "Clumsy birds have" blog, please be sure to keep this source http://tingdongwang.blog.51cto.com/1056852/685737

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/home/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.