3

I'm making a batch file to make log of computer (I need save some informations before format PC's on my work...)

So I found some commands to create this log, see:

rem -- Windows Version
wmic OS get Caption, OSArchitecture, ServicePackMajorVersion /format:htable > "%~dp0Config %computername%.html"

rem -- User Account
wmic USERACCOUNT get Caption,Name,PasswordRequired,Status /format:htable >> "%~dp0Config %computername%.html"

rem -- Installed Programs
wmic product get Description, InstallDate, Name, Vendor, Version /format:htable >> "%~dp0Config %computername%.html"

The problem is on this command:

wmic nicconfig get Description, MACAddress, IPAddress, IPSubnet, DefaultIPGateway, DNSServerSearchOrder, DHCPEnabled /format:htable >> "%~dp0Config %computername%.html"

On this case, I need show only adapters that have Mac Address...

On other case I do this to show only Enable Adapters:

wmic NIC where NetEnabled=true get Name, Speed, PNPDeviceID /format:htable >> "%~dp0Config %computername%.html"

But now, I need check for not empty values. How I can check if return not empty value? for take only values that have Mac Address?

I try this but does't work:

wmic nicconfig where MACAddress!='' get Description, MACAddress, IPAddress, IPSubnet, DefaultIPGateway, DNSServerSearchOrder, DHCPEnabled /format:htable >> "%~dp0Config %computername%.html"

Sorry for my bad english =)

4

WMIC uses a SQL dialect. An empty string (0 length string) is not the same as NULL (no value).

wmic nicconfig where "MACAddress is not null" get ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.