Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 19, 2017, 10:24 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: I need a batch command to stop the process and exit immediately when it finds th  (Read 417 times)

johnny09033

  • Participant
  • Joined in 2017
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
I need a batch command to stop the process and exit immediately when it finds this error:
connection error

the batch works with a certain tool and these are some benchmarks if they help something
The script I own closes the process in these situations and I want someone to help me add a new situation


:: Controll stopping
:: (1=enable,0=disable;)

:: Error exit codes
SET /A ERROR_UNKNOWN=-1
SET /A ERROR_OK=0
SET /A ERROR_NO_BOOKMARK_FOUND=1
SET /A ERROR_NO_MORE_DICTS=2
SET /A ERROR_FINDSTR_UNKNOWN_EXIT_CODE=3

and

1'st exit situation:
:: Check if the file exists
IF NOT EXIST "%filep%" (
ECHO File "%filep%" was not found. Assuming we ran out.
ECHO We did not find.
SET /A errno=%ERROR_NO_MORE_DICTS%
GOTO END
)

Another exit situation:

) ELSE (
:: tool did not run ok. No ideea why. The multitude of checks should have
:: prevented this.
ECHO %tool% exited with non-zero exit code. No ideea why. Contact dev.
SET /A errno=%ERROR_UNKNOWN%
GOTO END
)


The 3'rd situation:

:: Call command
%composedcmd%

:: Check if we ran ok
IF /I "%ERRORLEVEL%" EQU "%ERROR_OK%" (
:: Check if we found mamammia
FIND "Discovered mamammia" "%tooloutfile%" >NUL 2>&1 && (
ECHO mamammia.
GOTO END

I want to add new exit,so when finds this error EXIT:
connection error



THANK YOU!

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 3,066
    • View Profile
    • Donate to Member
Seems an interesting question.
Perhaps you can do in AHK. There are many experts here in this script language...