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

  • Home
  • SEARCH
  • 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 7980499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:05:40+00:00 2026-06-04T10:05:40+00:00

I have a simple .bat script that runs an external console program and when

  • 0

I have a simple .bat script that runs an external console program and when it completes it outputs a couple lines of data.

Is there a way to look for a keyword in the console output after external program has completed.

For instance:
The external program completes, the .bat file looks for the keyword: success, and if it’s found it saves the console output conversely if the keyword is: failed then the .bat program exits.

  • 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-04T10:05:42+00:00Added an answer on June 4, 2026 at 10:05 am

    Usually checks for success are done by directly checking the external process’s return code with the IF ERRORLEVEL construct:

    external.exe
    IF ERRORLEVEL 4 GOTO error1
    IF ERRORLEVEL 3 GOTO error2
    IF ERRORLEVEL 2 GOTO error3
    IF ERRORLEVEL 1 GOTO error4
    REM if you reached this point, external.exe reported success
    

    Of course this is dependent on the external program, so you might simply not be able to use it. In that case you can redirecting the output of the external program and using find to look for it; find uses a nonzero (don’t remember exactly) return code to signify that the target string was not found. So you can write:

    external.exe | find >nul "success"
    IF ERRORLEVEL 1 GOTO notfound
    REM if you reached this point, "success" was present in the output
    

    The >nul redirection makes sure that find will not actually output any matching text, since that’s not what you want to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple bat script that copies files from an known directory to
I have a simple bat file that runs an access macro when executed, i
I have a .bat script launching a java program. The java program deletes the
I have the following problem. I got a bat file that runs testcomplete test.
There are two things to note right off the bat.... The shell script runs
I have simple win service, that executes few tasks periodically. How should I pass
I have simple SSIS package which reads data from flat file and insert into
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
How to make .BAT file delete it self after completion? I have a simple
I have a batch file test.bat to start a powershell script: @pushd C:\myscripts powershell

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.