Tech Support Guy banner

Search string in batch file

18303 Views 3 Replies 2 Participants Last post by  draceplace
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?
Status
Not open for further replies.
1 - 4 of 4 Posts
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
Great, thanks. That helped me to get started.
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.
1 - 4 of 4 Posts
Status
Not open for further replies.
Top