I was pointed to a very good article by Josh Cook (full article at
with the info I am talking about 1/2 way down the page)
about routing and VPN connections. He included in this page a very simple script - but neglected to tell us vbscript dummies HOW to execute the doggone thing. Can someone take a look at this and tell me if it should be run from command line (saved as a .bat? compiled as an .exe?), or saved as an HTML page and loaded , whatever? The full script is also in the article referenced above, but here it is (comments and all): (***NOTE*** The lines are longer then what will fit in this window - in order to see this in readable form (and not confuse comments with script lines) please copy and paste it in Notepad or something.)
'Program: PPTP Route Addition Script
'Author: Joshua R. Cook
'Website: 'Date: 1.13.2005
'***********************
'Task: Variable Creation
'In Windows, the name of the VPN connection as it is appears in Network Connections
VPNConnection = "My Work VPN"
'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 = "192.168.1."
'The route command that should be executed, without the gateway
' - route add *network* mask *netmask*
RouteCommand = "route add 10.0.0.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
with the info I am talking about 1/2 way down the page)
about routing and VPN connections. He included in this page a very simple script - but neglected to tell us vbscript dummies HOW to execute the doggone thing. Can someone take a look at this and tell me if it should be run from command line (saved as a .bat? compiled as an .exe?), or saved as an HTML page and loaded , whatever? The full script is also in the article referenced above, but here it is (comments and all): (***NOTE*** The lines are longer then what will fit in this window - in order to see this in readable form (and not confuse comments with script lines) please copy and paste it in Notepad or something.)
'Program: PPTP Route Addition Script
'Author: Joshua R. Cook
'Website: 'Date: 1.13.2005
'***********************
'Task: Variable Creation
'In Windows, the name of the VPN connection as it is appears in Network Connections
VPNConnection = "My Work VPN"
'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 = "192.168.1."
'The route command that should be executed, without the gateway
' - route add *network* mask *netmask*
RouteCommand = "route add 10.0.0.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