How can I force the exit code to be zero for a windows cmd command without changing the way it behaves
The linux equivalent of what is mean is
netstat -an | grep 12035 || true
Something I tried is
C:\>netstat -ano | find "25000" | exit 0
Though it forces exit code 0, it does not show the desired output when successful
Eg:
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?
netstat -an | find "25000" || ver>nul
If the find
command raises errorlevel, execute a command that resets it., in this case the ver
command is used and its output discarded