If have scripted DHCPInfo.bat to set environment variables to a DHCP True/False indicator, IP address, subnet mask, default gateway, MAC address, DNS server address, DHCP server address, and network adapter description on the local computer.

The syntax for using DHCPInfo.bat is:

DHCPinfo TrueFalse IPaddress SubNetMask DefGateWay MACaddress DNSsrv DHCPsrv NICdesc

Where:

<b>TrueFalse</b>    is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain a <b>T</b> if <b>DHCP</b> is enabled or an <b>F</b> if it is not enabled.

<b>IPaddress</b>    is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the IP address, or <b>NONE</b>.

<b>SubNetMask</b>   is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the subnet mask, or <b>NONE</b>.

<b>DefGateWay</b>   is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the default gateway, or <b>NONE</b>.

<b>MACaddress</b>   is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the <b>MAC</b> address, or <b>NONE</b>.

<b>DNSsrv</b>       is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the <b>DNS</b> server address, or <b>NONE</b>.

<b>DHCPsrv</b>      is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the <b>DHCP</b> server address, or <b>NONE</b>.

<b>NICdesc</b>      is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the network adapter quoted description.
DHCPInfo.bat contains:
<font size="1">
@echo off
if \{%8\}==\{\} @echo Syntax DHCPinfo TrueFalse IPaddress SubNetMask DefGateWay MACaddress DNSsrv DHCPsrv NICdesc&goto :EOF
setlocal
if exist "%TEMP%\DHCPinfo.vbs" goto doit
@echo set IPConfigSet = GetObject("winmgmts:\{impersonationLevel=impersonate\}!root\cimv2").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")>"%TEMP%\DHCPinfo.vbs"
@echo for each IPConfig in IPConfigSet>>"%TEMP%\DHCPinfo.vbs"
@echo.    wscript.echo <div class="Contentquote"><center>" ^& IPConfig.DHCPEnabled(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.IPAddress(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.IPSubnet(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.DefaultIPGateway(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.MACAddress(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.DNSServerSearchOrder(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.DHCPServer(i) _>>"%TEMP%\DHCPinfo.vbs"
@echo. ^& </center></div>,<div class="Contentquote"><center> ^& IPConfig.Description(i) ^& </center></div>">>"%TEMP%\DHCPinfo.vbs"
@echo.next>>"%TEMP%\DHCPinfo.vbs"
:doit
for /f "Tokens=1-7* Delims=," %%a in ('cscript //nologo "%TEMP%\DHCPinfo.vbs"') do (
 set a1=%%a
 set a2=%%b
 set a3=%%c
 set a4=%%d
 set a5=%%e
 set a6=%%f
 set a7=%%g
 set a8=%%h
)
if /i "%a1%" EQU "True" set a1=T&goto strip
set a1=F
:strip
if %a2% EQU "" (
  set a2=NONE
  ) ELSE (
  set a2=%a2:"=%
)
if %a3% EQU "" (
  set a3=NONE
  ) ELSE (
  set a3=%a3:"=%
)
if %a4% EQU "" (
  set a4=NONE
  ) ELSE (
  set a4=%a4:"=%
)
if %a5% EQU "" (
  set a5=NONE
  ) ELSE (
  set a5=%a5:"=%
)
if %a6% EQU "" (
  set a6=NONE
  ) ELSE (
  set a6=%a6:"=%
)
if %a7% EQU "" (
  set a7=NONE
  ) ELSE (
  set a7=%a7:"=%
)
endlocal&set %1=%a1%&set %2=%a2%&set %3=%a3%&set %4=%a4%&set %5=%a5%&set %6=%a6%&set %7=%a7%&set %8=%a8%
</font>