I have written a Vim plugin which shells out to run external commands. Two of the commands I run are diff and grep which can each exit with a non-z
diff
grep
VER>NUL
works for me.
For example,
MKDIR . || VER>NUL
issues an error message, but it sets %ERRORLEVEL% to 0.
%ERRORLEVEL%