English 中文(简体)
Check if WMIC is installed, writing data into files from batch file
原标题:

I am using the Windows Management Instrumentation Command-line (WMIC) for reading data from a computer like it s Hardware components and IP settings.

As I am using a batch file (Windows) for filling files for each computer/node with data the query logic is implemented there. So far it has been working quite good on my computer and others I have tried on.

The problem is on computers where the WMIC has not been used before, it s neccessary to (automatically) be installed at the first query/execution. This is why the console program prints out "Please wait while WMIC is being installed".

As I am writing to my file this is a problem: I don t want to have this string in it. Another problem is, that if the string is output it crashes all my file. "Please wait while WMIC is being installed" is represented in ASCII, the results of the data queries are somehow written as ASCII characters with leading zeros (multi-byte character set? unicode? ...).

Does someone know how to check if WMIC is alread installed? Or: how to ignore the string? Or: do I really have to implement a converter in my file viewer which checks for the string/ character set?

最佳回答

Since that is only printed on the very first run of WMIC, you can just make two calls. One dummy one to eat away the string:

wmic foo >nul 2>&1

and after that what you actually wanted to execute.

问题回答

暂无回答




相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签