Check if WMIC is installed, writing data to files from a batch file

I use the Windows Management Instrumentation (WMIC) command line to read data from a computer, such as hardware components and IP settings.

Since I use a batch file (Windows) to populate files for each computer / node with data, the request logic is implemented there. So far, it has worked quite well on my computer and others that I have tried on.

The problem is related to computers on which WMIC has not been previously used; it is necessary (automatically) to install it upon first request / execution. This is why the console program displays "Please wait while WMIC is installed."

As I write to my file, this is a problem: I do not want this line in it. Another problem is that if a line is output, it flushes my entire file. “Wait while the WMIC installation” is presented in ASCII, the data query results are somehow written as ASCII characters with leading zeros (multibyte character set? Unicode? ...).

Does anyone know how to check if WMIC is installed? Or: how to ignore a string? Or: do I really need to implement a converter in my file viewer that checks the character set / characters?

+3
source share
1 answer

Since this is only printed the first time WMIC is started, you can simply make two calls. One dummy to eat a string:

wmic foo >nul 2>&1

.

+3

All Articles