This is the example, a shortcut was installed to this code
:
@echo off
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
:: $Header: C:/DBAREIS/Projects.PVCS/Win32/ScriptingTipsAndTricks/EXAMPLE[cmd].FILE CONTAINS [see if a file contains some text].cmd.pvcs 1.0 11 Jul 2014 19:31:02 USER "Dennis" $
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
setlocal
set FailureText=cannot
::--- Create a file with the commands output --------------------------------
echo DO SOMETHING (assume we can't trust the ERRORLEVEL but on it's failure
echo the output will contain the text "%FailureText%").
set OutputFile=%TEMP%\SomeProcess-OUTPUT.txt
set SOMECMD=dir "z:\NoSuch\NoSuch.txt"
echo [%FailureText%] Sanity Check > "%OutputFile%" 2>&1
%SOMECMD% > "%OutputFile%" 2>&1
::--- Type the result so you can see it -------------------------------------
echo.&echo.
echo -------------[ SOF ]---------------
type "%OutputFile%"
echo -------------[ EOF ]---------------
echo.&echo.
::--- See if the file contains the text (case insensitive search) -----------
set FAILED=Y
find.exe /I "%FailureText%" "%OutputFile%" >nul 2>&1
if errorlevel 1 set FAILED=N
echo CMD FAILED = %FAILED%