WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Capture Control Break

 Keywords: Capture Control Break Cntrl Ctrl Brake Brk ctrl-break 

Question:

I'm trying to recognise when the user terminates a wbt process so that I can write to a log before it exits completely.

I've looked at IntControl 72, but I think that only works for the user cancelling the scipt via dialogs, rather than "194: Execution terminated by user request".

Answer:

Sorry no way to accomplish what you are asking; a Ctrl-Break abruptly cancels the script, and therefore no further processing can occur.

One option you coould try is calling the script from another WinBatch script. Then setting an 'exit code' in the called script that can be checked by the calling script. The calling script would need to call RunShell and use the @GETEXITCODE parameter, which will cause the exit code of an application that is launched with the RunShell function will be returned. This is the same as specifying @WAIT, except that on success the function will return the exit code of the application that was launched.

In calling script you can check the value of exit code. If the script was unfinished (i.e. user Ctrl-breaked) then the exit code would be set to some special value.

For Example

;Main.wbt
exitcode = RunShell( DirScript():'secondary.wbt', '', '', @NORMAL, @GETEXITCODE ); Zero on success, positive value on error/ctrl-break
Pause('ExitCode is', exitcode)
;Add code here to check exit code. If non zero then write to log
Exit


;Secondary.wbt
; Set Exit code to positive value for incomplete
IntControl(1000,999,0,0,0)

For x = 1 To 10
     TimeDelay(1)
Next

; Set Exit code to 0 for success
IntControl(1000,0,0,0,0)
Exit
This is a common use of Exit Codes.
Article ID:   W17909
Filename:   Capture Control Break.txt
File Created: 2010:12:17:15:32:58
Last Updated: 2010:12:17:15:32:58