English 中文(简体)
How to suppress the output of wmic
原标题:

Does anyone know how to suppress the msg "No Instance(s) Available." from the following command? Your help is highly appreciated in advance!

wmic process where (name="java.exe") get commandline | findstr /i /c:"xxx" 1>nul 2>&1
问题回答

You have 2 choices where to place the 2>nul, either

2>nul wmic process where (name="java.exe") get commandline | findstr /i /c:"xxx"

or you can do

wmic process where (name="java.exe") get commandline 2>nul | findstr /i /c:"xxx"

You can also pipe stderr into stdout making it visible for your findstr command (thus ignoring "No Instance(s) Available." due to your filter):

wmic process where (name="java.exe") get commandline 2>&1 | findstr /i /c:"xxx"




相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签