Search string in batch file

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

difaz23

Thread Starter
Joined
Jun 27, 2005
Messages
5
This is probably an easy question for you guys but I am trying to search a string that I pass to my batch file for the term "failure" and perform an action if the text is found within that string. How can I accomplish this?
 
Joined
Jun 8, 2001
Messages
2,583
Here is an example of installing a new version of winzip. each time I install I post the computer name, time/date and version to ziplog.csv. The first 'findstr' writes the first line(record) it finds to wz.txt if it finds the computer name. If not go install. If computer name is found I check the version in the log (not in wz.txt)...delete wz.txt at the end of the routine, it is basically at temp file written to C:\.

:Check_Install_Log
findstr %computername% \\servername\Downloads\WinZip9.1\ziplog.csv>wz.txt
if errorlevel 1 GOTO Install
echo 9.0 already installed

:Check_Version
findstr "WINZIP9sr1" wz.txt
if errorlevel 1 GOTO Install

echo SR1 already installed
 
Joined
Jun 8, 2001
Messages
2,583
I just reread my comment and found an error...

"If computer name is found I check the version in the log (not in wz.txt)..."

I do actually look in wz.txt for the version. Because the first 'find' writes that complete record in there (from the log).

Later in this routine if ever thing is successfull I write to the log then if I try to install again this routine can kick you out.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top