Batch file loop and string compare

July 25, 2010 at 00:03:35
Specs: Windows XP, Intel

Making a batch file to run on multiple WinXP SP3 computers. I am installing new software on multiple computers and am calling the installation .exe file using a batch file. The problem is the program is not fully installed when the .exe quits as the .exe file calls an .msi file to finish off the install.
I am trying to check if a string/sentence exists in a text file that i am writing a. install log to, and if it does then execute another program, else if it doesn't exist, then check the text file again. This needs to be repeated until the string appears in the text file. Lines of text are being added to this file over short time period, about 4 minutes, during the install.

I have looked into batch commands and managed to figure out how to do a simple check for a string, for example:

findstr /i /c:"Dynamics CRM Successfully installed" c:\crmInstallLog.txt

But i cannot sort out how to tell if it has been found, meaning the install has finished.
Any ideas/example please?


See More: Batch file loop and string compare

Report •

July 25, 2010 at 18:40:19
findstr /i /c:"Dynamics CRM Successfully installed" c:\crmInstallLog.txt >NUL
if errorlevel 1 echo Text not found.

Report •

July 26, 2010 at 02:39:26
Thanks Razor2.3, very close with your suggestion.

got this to work. Have been testing this on a Win 7 machine at home so will test tomorrow at work on a WinXP box.

@echo off
findstr /i /c:"Windows Installer installed the product" e:\clientinstalllog.txt >2
if %errorlevel% EQU 0 (goto LABEL0) else (goto LABEL1)

echo Found it.
goto END

echo Text not found.


Report •
Related Solutions

Ask Question