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 apprecia开发者_运维技巧ted 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"
精彩评论