文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>VPN 创建 VBS脚本

VPN 创建 VBS脚本

时间:2010-11-08  来源:linuxfly

'Program:     PPTP Route Addition Script
'Author:        Joshua R. Cook
'Website:       http://www.joshcook.net/
'Date:          1.13.2005
'***********************
'Task: Variable Creation

'In Windows, the name of the VPN connection as it is appears in Network Connections
VPNConnection = "VPN-Name"

'The username for the VPN connection
VPNUsername = "username"

'The password for the VPN connection
VPNPassword = "password"

'The IP range that is provided to PPTP clients, without that last octet (this is used for matching purposes)
PPTPNetwork = "xxx.xxx.xxx.xxx"

'The route command that should be executed, without the gateway
' - route add *network* mask *netmask*
RouteCommand = "route add 192.168.xx.0 mask 255.255.255.0"

'*********************************
'Task: Establish Dialup Connection
        
Set Shell = CreateObject("WScript.Shell")
Shell.Run "Rasdial " & VPNConnection & " " & VPNUsername & " " & VPNPassword, 6, True
Set Shell = Nothing

'*********************************
'Task: Obtain *Correct* IP Address

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
        
For Each objAdapter In colAdapters

        If InStr(objAdapter.IPAddress(0), PPTPNetwork) > 0 Then VPNIPAddress = objAdapter.IPAddress(0)
        
Next
        
Set colAdapters = Nothing
Set objWMIService = Nothing

'*************************
'Task: Add Route Statement

Set Shell = CreateObject("WScript.Shell")
Shell.Run RouteCommand & " " & VPNIPAddress, 6, True
Set Shell = Nothing
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载