Force code completion code for Windows command line commands

How to make exit code be null for cmd windows command without changing behavior

The linear equivalent of the mean

netstat -an | grep 12035 || true 

I tried something

 C:\>netstat -ano | find "25000" | exit 0 

Although it gives exit code 0, it does not show the desired result if successful

For instance:

 C:\>netstat -ano | find "25000" TCP 0.0.0.0:25000 0.0.0.0:0 LISTENING 4832 C:\>netstat -ano | find "25000" | exit 0 

Any idea if there is a way?

+5
source share
1 answer
 netstat -an | find "25000" || ver>nul 

If the find raises errors, run the command that resets it. In this case, the ver command is used, and its output is discarded

+5
source

Source: https://habr.com/ru/post/1210510/


All Articles