1

Could anyone tell me as to how I can get the DHCP address using wmic command. I need the LAN DHCP and the WiFi DHCP. Is there a WHERE clause I could use to get this. The output has to be in a single line.

Let me paste the code below which will help you understand The last line of the below code is what I tried for DHCP but I am unable to filter it out exactly. My only question is, similar to how I got the HDD space using the where clause, is there a similar where clause for obtaining the DHCP address of LAN and WiFi.

@echo off
for /f "delims== tokens=2" %%i in ('wmic path win32_logicaldisk where "drivetype = 3" get size /value') do SET HDDSIZE=%%i
for /f "delims== tokens=2" %%i in ('wmic path Win32_NetworkAdapterConfiguration where "ipenabled=true" get dhcpserver /value') do SET DHCP=%%i

set outputfile="C:\dell\%SERVICETAG%.csv"

echo HDDSize,DHCP>>%outputfile%
echo %HDDSIZE%,%DHCP%>>%outputfile%
Compo
  • 36,585
  • 5
  • 27
  • 39
SS97
  • 115
  • 1
  • 14
  • 1
    Take a look at this [Get Interface name, IP and MAC in Windows Command line](http://stackoverflow.com/questions/27160042/get-interface-name-ip-and-mac-in-windows-command-line) – Hackoo Sep 11 '16 at 17:36
  • See `SetLocal EnableDelayedExpansion` then in the `do` part of `for` - `SET DHCP=!DHCP!%%I,`. See `for /?` and `setlocal /?` for help on variable expansion. –  Sep 11 '16 at 20:55

0 Answers0