Apr 062008
 

PPPアダプタに割り当てられたIPアドレスを調べてルーティング設定するためのスクリプト。

' ルーティングテーブル追加

Set WshShell = CreateObject("WScript.Shell")

Set NetworkAdapters = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
	("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = 'WAN (PPP/SLIP) Interface'")

For Each Adapter In NetworkAdapters
	IPAddress = Adapter.IPAddress
	If IsArray(IPAddress) Then
		WshShell.Run "route add 10.0.10.0 mask 255.00.0.0 " & IPAddress(LBound(IPAddress)) & " metric 1", 0, Ture
		WshShell.Run "route add 172.16.10.0 mask 255.240.0.0 " & IPAddress(LBound(IPAddress)) & " metric 1", 0, Ture
		WshShell.Run "route add 192.168.0.0 mask 255.255.0.0 " & IPAddress(LBound(IPAddress)) & " metric 1", 0, Ture
	End If
Next

Sorry, the comment form is closed at this time.