在完成了Windows XP下VPN自动创建并配置连接后,其实我们还需要对Windows 7下VPN自动配置做一个介绍,因为目前实际上很多企业也已经开始进行了大批量的Windows 7的使用,而且很多用户目前也在逐渐向Windows 7系统迈进,那么如何让Windows 7用户也能有不错的用户体验呢?如何简化这些用户的VPN创建也成为了我们需要考虑的内容,继续前面的内容我来分享一下,我在Windows 7下的配置。
在Windows 7的VPN批处理脚本中还实现了在TMG-VPN中完成的SSTP_VPN模式时注册表的导入,当然,我们说只有您的企业中已经安装并配置好了SSTP—VPN时可能您才需要导入这个注册表键值,如果仅仅是需要完成VPN的自动创建配置,那么也可不添加这部分的批处理脚本内容。
好,接下来,我们就一起来看看如何在Windows 7下实现VPN连接自动创建吧。
@echo off & color 5a
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo Windows 7_VPN连接配置
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo 配置过程中,请勿进行任何操作,以保证配置顺利完成!
echo.
echo. 祝您工作愉快、顺利!
echo.
echo 确认安装配置VPN请按任意键继续!
pause
cls
@echo off
echo 正在检查VPN1.Test.com是否存在,请稍等……
@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已经存在或创建完成!
cls
echo 正在检查VPN2.Test.com是否存在,请稍等……
@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已经存在或创建完成!
cls
echo 正在检查VPN3.Test.com是否存在,请稍等……
@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 正在创建PEKD1.Vancl.cn连接,请稍等……
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 100 >>Test_VPN.VBS
echo WshShell.SendKeys "%%+I" >>Test_VPN.VBS
echo WScript.Sleep 100 >>Test_VPN.VBS
echo WshShell.SendKeys "VPN1.Test.com" >>Test_VPN.VBS
echo WScript.Sleep 100 >>Test_VPN.VBS
echo WshShell.SendKeys "%%+E" >>Test_VPN.VBS
echo WScript.Sleep 500 >>Test_VPN.VBS
echo WshShell.SendKeys "VPN1.Test.com">>Test_VPN.VBS
echo WScript.Sleep 100 >>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 正在完成VPN1.Test.com_VPN连接配置,请稍等!
ping 127.0.0.1 -n 10>nul
cls
echo VPN1.Test.com连接创建完成,即将为您创建VPN1.Test.com桌面快捷方式,请稍等……
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桌面快捷方式创建完成,即将为您配置VPN2.Test.com连接,请稍等……
ping 127.0.0.1 -n 10>nul
goto:VPN2.Test.com
:addVPN2.Test.com
echo 正在创建PEKD2.Vancl.cn连接,请稍等……
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 100 >>Test_VPN.VBS
echo WshShell.SendKeys "%%+I" >>Test_VPN.VBS
echo WScript.Sleep 100 >>Test_VPN.VBS
echo WshShell.SendKeys "VPN2.Test.com" >>Test_VPN.VBS
echo WScript.Sleep 100 >>Test_VPN.VBS
echo WshShell.SendKeys "%%+E" >>Test_VPN.VBS
echo WScript.Sleep 500 >>Test_VPN.VBS
echo WshShell.SendKeys "VPN2.Test.com" >>Test_VPN.VBS
echo WScript.Sleep 100 >>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 正在完成VPN2.Test.com_VPN连接配置,请稍等!
ping 127.0.0.1 -n 10>nul
cls
echo VPN2.Test.com连接创建完成,即将为您创建VPN2.Test.com桌面快捷方式,请稍等……
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桌面快捷方式创建完成,即将为您配置VPN3.Test.com连接,请稍等……
ping 127.0.0.1 -n 10>nul
goto:VPN3.Test.com
:addVPN3.Test.com
echo 正在创建VPN3.Test.com连接,请稍等……
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 100 >>Test_VPN.VBS
echo WshShell.SendKeys "%%+I" >>Test_VPN.VBS
echo WScript.Sleep 100 >>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 500 >>Test_VPN.VBS
echo WshShell.SendKeys "VPN3.Test.com" >>Test_VPN.VBS
echo WScript.Sleep 100 >>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 正在完成VPN3.Test.com_VPN连接配置,请稍等!
ping 127.0.0.1 -n 10>nul
cls
echo VPN3.Test.com连接创建完成,即将为您创建VPN3.Test.com桌面快捷方式,请稍等……
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桌面快捷方式创建完成.
del Test_VPN.VBS
ping 127.0.0.1 -n 10>nul
cls
goto:check_vpn
:check_vpn
echo 即将对配置VPN进连接行校对,请稍后……
@echo off
choice /t 5 /d y /n >nul
echo VPN1.Test.com 配置校对完成!
@echo off
choice /t 5 /d y /n>nul
echo VPN2.Test.com 配置校对完成!
@echo off
choice /t 5 /d y /n>nul
echo VPN3.Test.com 配置校对完成!
ping 127.0.0.1 -n 10>nul
goto:creat_pbk
:creat_pbk
echo 即将为您生成Test_VPN.PBK桌面文件
@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 即将为您导入SSTP相关注册表文件
@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 注册表导入完成!
choice /t 5 /d y /n>nul
del Test_VPN.vbs
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo 感谢您的耐心等待,Windows 7_VPN配置完成
echo 现在您可以使用配置好的任意一个做为连接点使用VPN
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo 感谢您的使用!
@echo off
set /p reset=按Y键重新启动计算机应用注册表键值,按任意键退出稍后自行重启:
if %reset%==y (goto :reboot) else (goto :noreboot)
:reboot
shutdown /r /t 0
:noreboot
echo 感谢您的使用!
choice /t 2 /d y /n>nul
exit
:no
cls
echo off
echo 系统中已存在VPN1.Test.com、VPN2.Test.com和VPN3.Test.com连接,按任意键退出 & pause
本文出自 “笨鸟先飞” 博客,请务必保留此出处http://tingdongwang.blog.51cto.com/1056852/685737
查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/home/