How to? Stop a command in the middle of its operation

Feb 23, 2012
240
3
In the regular DOS command prompt, I can hit Ctrl-C to stop an operation in its tracks. So, let's say I run a long operation in a loop, iterating over all subdirectories, like this:
for /d /r %G in ("*") do [command] %G
with the regular command prompt, I can stop it at any time with Ctrl-C. However, I can't find any way to do so in TCC. To be sure, there is an option to support Ctrl-C in batch files, but that doesn't seem to help here (perhaps because this is not a batch file with multiple lines, but rather a single line command).
As far as I can tell, the only thing I can do to stop it is to close the TCC window altogether - not a great solution because I lose all my history!
 
Feb 23, 2012
240
3
Well, I'm running a custom utility that I wrote, but I can reproduce the problem with the simple "dir" command. Go to your root directory and run:
dir /s
This will recurse through all directories, outputting all files. On my system, with nearly a million files, this takes a bit of time, even in TCC. I would expect, however, to be able to stop it with Ctrl-C. However, Ctrl-C does not work for me.
Similarly, if we do the same thing in a for loop on the command line, like this:
for /d /r %G in ("*") do dir %G
Here too, Ctrl-C does not affect it
 
Feb 23, 2012
240
3
OK, I found the problem. When I first installed TCC, I wanted to copy and paste text as I was used to, and it seems strange that I could not do it with Ctrl-C, so I set Ctrl-C to be "copy" in my keyboard shortcuts. But it seems that in doing so, I canceled my ability to break within a program!
Thanks anyway for your help.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
DIR /S is what I tried, and Control-C definitely interrupts it here.

Is this in a Take Command tab, or in a standalone TCC console? If you're having the issue in a Take Command tab, you might go to Options / Configure Take Command... / Tabs, and check that the tick boxes marked 'Left Ctrl Key' and 'Right Ctrl Key' are both turned off.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
OK, I found the problem. When I first installed TCC, I wanted to copy and paste text as I was used to, and it seems strange that I could not do it with Ctrl-C, so I set Ctrl-C to be "copy" in my keyboard shortcuts. But it seems that in doing so, I canceled my ability to break within a program!

Aha; that makes sense! I'd forgotten there was such an option.
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
OK, I found the problem. When I first installed TCC, I wanted to copy and paste text as I was used to, and it seems strange that I could not do it with Ctrl-C, so I set Ctrl-C to be "copy" in my keyboard shortcuts. But it seems that in doing so, I canceled my ability to break within a program!

The problem is that you want to overload Ctrl-C to mean two different things. You can actually do that with Take Command by specifying one Ctrl key (left or right) that will be handled by Take Command; the other one will be passed to the current tab window. So for example, a (left)Ctrl-C can copy, and a (right)Ctrl-C can interrupt.
 
Oct 21, 2017
1
0
This thread is old but the case i have is directly relevant to it. Can someone help with this :dummy:

Ctrl-C doesn't work while "pause" is executing (Press any key to continue . . .) within a procedure. I have a loop with "pause" added during testing time. The code I am using is to loop through direct sub-folders then for each subfolder execute a call to an executable (.exe) named here CmdThatTakesLongTimeToRun. During testing I'm replacing the call to the executable with an echo of what it will look like. Somehow in doing so Ctrl-C doesn't work and I have to press a number of times equal to direct subfolders until the for loop completes!


My Looks like this:

set par_test_DoSmthProcedure =Yes
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set parentFolder=%cd%
for /f "tokens=*" %%x in ('dir /b/ad') do (
cd "%%x"
echo processing folder "%%x"
pause
call :DoSmthProcedure
cd "%parentFolder%"
)
goto :eof

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DoSmthProcedure

if defined par_test_DoSmthProcedure (

echo.CmdThatTakesLongTimeToRun%parameters%
) ELSE (
CmdThatTakesLongTimeToRun %parameters%
)
echo.Completed @ %date% -- %time%
exit /b

:eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


The example below is the output I get whether i press ctrl-c every time or any other key, kind of stuck until done :banghead: . The output of echo in DoSmthProcedure is omitted for clarity.

processing folder "pdf"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:14.67
processing folder "mp4"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:15.09
processing folder "jpg"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:15.30
processing folder "wmv"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:15.43
processing folder "mts"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:15.69
processing folder "avi"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:15.83
processing folder "bmp"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:16.07
processing folder "png"
Press any key to continue . . .
Complete Time @ 10/21/2017 -- 13:55:16.83
processing folder "vob"
Press any key to continue . . .
 
Apr 2, 2011
1,441
10
54
North Carolina, USA
@Sam40 hve you tried "ON BREAK" ??

Activation of ON BREAK
ON BREAK will execute command if the user presses Ctrl-C or Ctrl-Break.

or
Purpose: Enable or disable Ctrl-C and Ctrl-Break
Format: BREAK [ON | OFF]
Usage:
BREAK OFF will disable all Ctrl-C and Ctrl-Break handling in TCC (though not necessarily in child processes). In CMD, BREAK OFF doesn't actually do anything, so setting it in TCC will introduce a possible incompatibility with existing batch files.
 
Dec 7, 2009
238
2
Left Coast, USA
@Sam40
I'm wondering if you can get rid of the cmd.exe-style instructions and go to a fully Take-Command-ish approach. I've tried the following under TCC 20 (I'm always slow to upgrade) and it displays what I expect it to display. If your batch file must be fully compatible with cmd.exe, none of the following applies. In which case, this reply can maybe be used for wrapping fish or something. :)

Code:
setlocal
on break CANCEL
set par_test_DoSmthProcedure=Yes

do _thisdir in /s /a:d *
    pushd "%@full[%_thisdir]"
    echo  Processing in %_cwd
    pause Quit: Control+C -- or press some other key to continue...
    iff defined par_test_DoSmthProcedure then
        echo  do one kind of procedure
    else
        echo  do some other kind of procedure
    endiff
    echo  Completed: %_date @ %_time
    echo.
    popd
enddo
 
Similar threads
Thread starter Title Forum Replies Date
vefatica Stop TPIPE /EOL removing bad EOLs (and TPIPE changine EOLs)? Support 2
vefatica Start/stop screensaver from TCC? Support 12
L WAD In console, tabs are rendered with non-uniform tab-stop spacing Support 16
T Fixed V18 debugger crashed on stop button Support 2
B How to? why does my BTM stop Support 2
F How to? Stop hijacking control-shift-z Support 6
krischik Stop Script after Syntax Error. Support 6
Dmitry L. Kobyakov How to? How to remove the record of the old version of the Take Command? Support 5
D Can alias pass parameters to for command? Support 3
samintz How to? Search for %(command) in Help? Support 1
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
K Take Command fox XP? Support 7
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
fpefpe How to? command echo in title line/bar Support 2
U Command help on file names Support 5
vefatica Command line DO with no closing parenthesis? Support 9
vefatica Command history search is off Support 7
H How to? How can I say "if the command separator is not ~ then setdos /C~" Support 8
N Command execution slows down in TCC Prompt after a while Support 6
R Long commands retrieved from command history have blank line when wrapped Support 20
jpeni Take Command Language Examples Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 26.02.41 Uploaded Support 0

Similar threads