HuyPV
Wednesday, August 25, 2010
'C:\huypv>tracert 192.168.176.190
'
'Tracing route to 192.168.176.190 over a maximum of 30 hops
'
' 1 9 ms 14 ms 17 ms 10.57.2.1
' 2 * 16 ms 9 ms 10.57.4.5
' 3 8 ms 8 ms 25 ms 192.168.191.57
' 4 22 ms 13 ms 16 ms 192.168.191.53
' 5 7 ms 20 ms 6 ms 192.168.191.83
' 6 6 ms 6 ms * 192.168.191.141
' 7 26 ms 24 ms 23 ms 192.168.191.42
' 8 5 ms 5 ms 7 ms 192.168.176.190
'
'Trace complete.
'
'C:\huypv>route -p add 192.168.176.0 mask 255.255.255.0 192.168.208.254
'
'C:\huypv>tracert 192.168.176.190
'
'Tracing route to 192.168.176.190 over a maximum of 30 hops
'
' 1 7 ms 5 ms 5 ms 192.168.208.254
' 2 4 ms 4 ms 5 ms 192.168.191.57
' 3 3 ms 3 ms 3 ms 192.168.191.53
' 4 5 ms 5 ms 6 ms 192.168.191.83
' 5 5 ms 4 ms 6 ms 192.168.191.141
' 6 6 ms * 5 ms 192.168.191.42
' 7 36 ms 36 ms 31 ms 192.168.176.190
'
'Trace complete.
'##################################################################
strComputer = "." 'a dot(.) for this computer
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim colAdapters
Set colAdapters = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
Dim selectedIPGateway, selectedSubnet
selectedIPGateway = ""
For Each objAdapter in colAdapters
'WScript.Echo "Description : " & objAdapter.Description
If InStr(objAdapter.Description, "Ethernet") >= 1 then
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
'WScript.Echo "IP address: " & objAdapter.IPAddress(i)
selectedIPGateway = objAdapter.DefaultIPGateway(i)
'selectedSubnet = objAdapter.IPSubnet(i)
Exit For
Next
End if
End if
Next
If Len(selectedIPGateway) = 0 Then
Msgbox "Auto detect Ethernet NIC failed", 0, "PVH"
Wscript.Quit
End if
Dim strXMPPServer
strXMPPServer = "192.168.176.190"
selectedSubnet = "255.255.255.0"
Dim enterCounter
enterCounter = 1
Do
If enterCounter <> 1 Then
strPrompt = "Enter valid address"
Else
strPrompt = "Enter XMPP Server NETWORK: 192.168.176.0 instead of 192.168.176.190"
End if
strXMPPServer = InputBox(strPrompt, "PVH", "192.168.176.0")
enterCounter = 2
Loop Until Len(strXMPPServer) > 0
Set oWshShell = CreateObject("WScript.Shell")
strCommand = "route -p add " & strXMPPServer & " mask " & selectedSubnet & " " & selectedIPGateway
'WScript.Echo strCommand
oWshShell.Run strCommand, 1, TRUE
Title:
VBS route add VPN Local network adapter
Description:
'C:\huypv>tracert 192.168.176.190 ' 'Tracing route to 192.168.176.190 over a maximum of 30 hops ' ' 1 9 ms ...
...
Rating:
4