ASKER
ASKER
ASKER
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each obj in colItems
if obj.DefaultIPGateway <>"" then Wscript.Echo obj.DefaultIPGateway
next
save it as getgateway.vbs and call that from batch with
@echo off
for /f "tokens=*" %%a in ('cscript //nologo getgateway.vbs') do if not "%%a"=="" set gateway=%%a
echo The gateway is %gateway%
Not sure how well that works with DHCP, let us know.
ASKER
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each obj in colItems
for each gw in obj.DefaultIPGateway
wscript.echo gw
next
next
ASKER
ASKER
ASKER
Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.
TRUSTED BY
@echo off
for /f "tokens=*" %%a in ('yourcommand.exe') do echo %%a, %%b, %%c
would run down each line of output of "yourcommand.exe" which you add in single quotes in the middle of the for line and and split the lines after every space and then assign first "field" to %%a, second to %%b etc. so if yourcommand.exe output
abc def ghi
then it would show
abc, def, ghi
Steve