That is both a simple and a complicated problem at once.
Ping'ing is trivial (you use the Win32_PingStatus WMI class, or if you have older OS'es i.e. win2k and below, then you have have to call ping.exe and parse the text output).
As for the gateways, you can enumerate them (string DefaultIPGateway[]; property of the class), and set it with the SetGateways method of the same class. All good so far.
Now the hard part: how do you determine which NIC to use it against if it has more than one? (this box has 4)
A quick and dirty script (5 minute job, could be a lot nicer), that works more or less blindly, and tries to set it on all NICs:
CODE
On Error Resume Next
strComputer = "."
Dim arrGateways(0)
arrGateways(0) = "192.168.1.1"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
If Not IsNull(objNicConfig.DefaultIPGateway) Then
strDefaultIPGateway = Join(objNicConfig.DefaultIPGateway)
Set colPings = objWMIService.ExecQuery ("SELECT * FROM Win32_PingStatus WHERE Address = '" & strDefaultIPGateway & "'")
For Each objPing in colPings
If objPing.StatusCode <> 0 Then
objNicConfig.SetGateways(arrGateways)
End If
Next
Else
'gateway is not set! uncomment next line to force set it
'objNicConfig.SetGateways(arrGateways)
End If
Next
Change the gateway IP from 192.168.1.1 to whatever you need to set it to. You can also make the array bigger, and add more values to it if you need more than one gateway.
Anything else just ask.