i want to be able to search through the command output for several different error conditions.
I have tried outputting the standard error to a tmp file and reading it back in. this does not appear to work reliably however.
i notice that even if the tmp file is updated i do not always read back in what has been written to it.
I sometimes see i am reading what was previously in the file, even though i am deleting the file each time, maybe there is some buffering i don't know about?
The other issue with the file reading is that the command i am using only seems to be able to read in one line, when i want to read all the contents, as there may be several errors.
There has to be a better way of doing what i want to do

Here is the code:
Code: Select all
@echo off
set VSINSTRPATH=%~1
set INSTRUMENTATIONDIR=%~2
echo using vsinstr path: %VSINSTRPATH%
echo storing instrumented files: %INSTRUMENTATIONDIR%
del logFile.txt
set TOSIGNDIR=tosign
mkdir %TOSIGNDIR%
echo.
echo Instrmenting exe's
For %%X in (*.exe) do (
echo Instrumenting %%X >> logFile.txt
"%VSINSTRPATH%\vsinstr.exe" -coverage %%X /OUTPUTPATH:%INSTRUMENTATIONDIR% 2> tmpFile
set /p vsinstrOutput= < tmpFile
del tmpFile
echo Start -- %vsinstrOutput% -- end
echo %vsinstrOutput% >> logFile.txt
echo %vsinstrOutput% | find "VSP2013"
if NOT errorlevel 1 echo VSP2013 found, Program will need to ruin as 32bit application
echo %vsinstrOutput% | find "VSP1011"
if NOT errorlevel 1 echo VSP1011 found, Need profiler flag to be enabled, error logged, no other action to take
echo %vsinstrOutput% | find "VSP2001"
if NOT errorlevel 1 (
echo VSP2001 found, exe/dll will need to be signed, Move instrumented files to tosign folder
move /y ".\"%INSTRUMENTATIONDIR%"\"%%X ".\"%TOSIGNDIR%
)
echo %vsinstrOutput% | find "VSP1030"
if NOT errorlevel 1 echo VSP1030 found Invalid, mismatched, or no PDB file was found, log error no other action to take
echo %vsinstrOutput% | find "VSP1005"
if NOT errorlevel 1 echo VSP1005 found Command line error: instrumentedfiles is invalid - OUTPUTPATH must refer to a valid, local directory
)
The above file is being called like this: fileoptest.bat "C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools" instrumentedfiles