Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:04:35+00:00 2026-06-07T00:04:35+00:00

I want to write a batch script statement where: FINDSTR has to check for

  • 0

I want to write a batch script statement where:
FINDSTR has to check for a string AND IF found then just print out FAILED and end the program
IF NOT FOUND then go check/look for another string AND IF FOUND then print out SUCCEEDED and close the program, IF NOT FOUND then print out the error message again.
Any ideas?

Here is what I did:

ECHO Checking the log file for errors...
FINDSTR /C:"Open failed" some_Log.txt && (ECHO Deployment FAILED. 
cscript //nologo success_mail.vbs 
pause) || FINDSTR "RC (return code) = 0" && (ECHO Deployment was successful.
cscript //nologo fail_mail.vbs
pause)

I don’t know why it is not working. Any help would be appreciated.

Here is what i my latest one looks like:

  ECHO Checking the log file for errors...
    FINDSTR /C:"Open failed" some_Log.txt some_Log.txt && (
     ECHO Deployment FAILED. 
     cscript //nologo fail_mail.vbs 
     GOTO offshore ) || (
      FINDSTR /C:"RC (return code) = 0" some_Log.txt && (
        ECHO Deployment was successful.
        cscript //nologo success_mail.vbs 
        GOTO offshore)
      )

And, it is not working. Do you see any errors? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:04:36+00:00Added an answer on June 7, 2026 at 12:04 am

    I see a couple of potential problems.

    • Your %workDir% or %filenm% could contain spaces or special characters. To be safe you should enclose them in quotes if you haven’t already done so in the values.

    • You must be careful when using both && and || operators. If the command(s) after the && fail, then it can cause the script to fall into the || section, even though the original command before the && succeeded. I’m worried about your CSCRIPT command to send mail. Even if it succeeds today, perhaps it could fail in the future and your logic could be impacted.

    • I’m guessing that the 2nd search string is supposed to be a phrase and not 5 different searches. Remember that search strings are delimited by space unless the /C option is used.

    • Your 2nd FINDSTR is hanging because you have neglected to provide a file as input, so it is waiting for data on stdin.

    I would structure your code like so

    ECHO Checking the log file for errors...
    set "file=%workDir%\%filenm%_DEV_Log.txt"
    set "search1=Error: Open failed because: No such file or directory"
    set "search2=RC (return code) = 0"
    set "err="
    FINDSTR /C:"%search1%" "%file%" && (set err=1) || (
      FINDSTR /C:"%search2%" "%file%" || set err=1
    )
    if defined err (
      ECHO Deployment FAILED.
      cscript //nologo success_mail.vbs "%filenm%_ddl_DEV.sql" "%file%"
      pause
    ) else (
      ECHO Deployment was successful.
      cscript //nologo fail_mail.vbs "%filenm%_ddl_DEV.sql" "%file%"
      pause
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a batch script under Windows to ping a specified range
I want to write a simple batch script that loads the Visual Studio build
I am new to perforce, I want to write batch script for copying same
Note : question regarding Windows shell I want to write a simple batch script
In my batch file I have the script: set myVar=/someLabel:%1 I want to write
I want to write a SELECT statement as follows: SELECT field_a FROM my_table WHERE
I want to write a batch file that will take the contents of a
I am trying to write a batch(for win) and a shell script for linux
How do I write a batch process on the Mac for pdf2swf, I want
I'm trying to write a batch script that errors if port 1099 is already

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.