Checks the default gateway
By nater

'nslacum 12/12/05
'This has functions only available in windows XP and will only run on those machines (and 2000)
'Determains what network you are on by the default gateway address and
'Then will perform task from ChkAddrs Sub If address matches NetGWaddrs


'Makes sure your running windows XP

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
If WshSysEnv("OS")="Windows_NT" Then
Else
Wscript.quit
End If

'***************************************************** **************************************

' Dictionary: A list of default gateways (vlans) to run an action one
'


Const TextMode = 1
Set ObjDictionary = CreateObject("Scripting.Dictionary")
ObjDictionary.CompareMode = TextMode

ObjDictionary.Add "Use IP address Here", "Use Vlan description" 'repeat if needed



'***************************************************** **************************************

'Checks Network Address

on error resume next

Set objWMIService = GetObject("winmgmts:{impersonationLevel=imperson ate}!")
Set colNicConfig = objWMIService.ExecQuery("SELECT * FROM " & _
"Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")


For Each objNicConfig In colNicConfig
WScript.Echo "Network Adapter: " & objNicConfig.Index
If Not IsNull(objNicConfig.DefaultIPGateway) Then
strIPAddresses = Join(objNicConfig.DefaultIPGateway)
Else
strIPAddresses = ""
End If
Call ChkAddrs
'For any additional adapters.
Next
Wscript.echo "ending"
Wscript.quit

'*****************************************************
' The ChkAddrs Sub
'*****************************************************
Sub ChkAddrs

If ObjDictionary.Exists(strIPAddresses) Then
Wscript.echo "You are on " & ObjDictionary.item(strIPAddresses)
Call runprogram1
Else
Wscript.echo "Your not on the specified network"
End If
ObjDictionary.RemoveAll

End Sub


'*****************************************************
' runprogram1 Sub
' This is your sub to run a program or do whatever

'*****************************************************
Sub runprogram1

Wscript.echo "running program"

End Sub

Rating:


0/5 based on 0 votes. The median rating is 0.

Submitted: 11/19/10 (Edited 11/19/10)

Description: Checks the default gateway of a pc and then can perform an action against what your gatway is. Use full for segmented (vlan) networks.

Tags:

Views: 52 views. Averaging 0 views per day.
In the most recent 30 day period, there've been 0 views.

Similar Articles:
Checks the default gateway
Comcast Sued For Unauthorized Credit Checks -
Bright House Cashed Customer Checks -- Repeatedly
Bright House Cashed Customer Checks -- Repeatedly
Bright House Cashed Customer Checks -- Repeatedly

Previous Article | Next Article