Why does my tcstart.btm sometimes terminate tcc.exe?

Jun 3, 2008
Temecula, CA
Here is my tcstart.btm. When I start up a new TCC.exe window, sometimes it runs to completion, leaving me a new TCC window, and sometimes it simply goes POOF! I added debugging to it so I could tell when it's exiting, and when it fails, it's always after creating debugJPc.txt. That makes no sense at all to me, especially since it creates JPc and then JPd consecutively, with no other code in between them. But that is the cessation point, every time. Yet sometimes it runs to success.

Note also that if I remove tcstart.btm from the TCMD directory, TCC always starts up with no problems.

Any ideas what might be wrong, or how I might better troubleshoot it?

@echo off
: This is executed each time a copy of TC/4NT is loaded. You can also create
: TCEND.BTM (4END.BTM) to execute when TC/4NT is exited.
on error gosub ErrorHandler
echo Executing %0
pushd %@path[%comspec]
echo a > c:\wip\debugJPa.txt
unalias *
echo b > c:\wip\debugJPb.txt
alias /r %@name[%comspec].als
echo c > c:\wip\debugJPc.txt
echo d > c:\wip\debugJPd.txt
unfunction *
function /r %@name[%comspec].fns
if exist %COMPUTERNAME%.fns function /r %COMPUTERNAME%.fns
echo e > c:\wip\debugJPe.txt
iff %@name[%comspec] == TCC then
rem remove zip and unzip internal commands
setdos /i-zip
setdos /i-unzip
echo f > c:\wip\debugJPf.txt
iff "%@search[FixPrompt.btm]" != "" then
call FixPrompt
set titleprompt=`%_cwd`
prompt [$t]-$g
echo g > c:\wip\debugJPg.txt
set COLORDIR=offline: black; hidden system:bright red; rdonly: bright black; dirs:bright green; com exe bat btm cmd vbs vbc js:bright yellow; zip arc arj lha cab tar z:bright magenta; c cs cpp h hpp rc odl mc frm bas cls ctl rul wbt:bright white
echo h > c:\wip\debugJPh.txt
set .vbc=%SystemRoot\system32\cscript.exe /nologo
if "%@search[isdev.exe]" != "" set .ism=start %@MaybeQuote[%@search[isdev.exe]]
echo i > c:\wip\debugJPi.txt
if %@instr[0,1,%@verinfo[%comspec%]] GT 6 alias pdir=*pdir /d
echo j > c:\wip\debugJPj.txt
if exist %COMPUTERNAME%.als alias /r %COMPUTERNAME%.als
echo k > c:\wip\debugJPk.txt
if (%_transient == 1 .OR. %_pipe == 1) quit
echo l > c:\wip\debugJPl.txt
if "%@search[env.btm]" != "" call env.btm
echo m > c:\wip\debugJPm.txt
rem no need to worry about restoring drives on second TC/4NT window
REM tasklist tcc > clip:
REM iff "%@clip[1]" == "**EOC**" then
REM call RestoreDriveMappings
REM endiff
setarray _TCCinstances[10]
echo %@execarray[_TCCinstances,tasklist tcc] >& nul
iff %_EXECARRAY == 1 then
call RestoreDriveMappings
unset /q _TCCinstances
echo n > c:\wip\debugJPn.txt
kill c:\wip\debugJP*.txt
echo Error received: ? = %?, _? = %_?, _SYSERR = %_SYSERR
May 20, 2008
Elkridge, MD, USA
My guess why log file c is created but d is not when TCSTART fails is delayed write - the command is queued for the OS to perform, but the process is cancelled already. I would try using the LOG command to create a command log in a single file.

Do you use global functions or aliases (with or without SHRALIAS)? If you do, the UNFUNCTION and UNALIAS commands will kill all functions and aliases in all other concurrent command processor instances, and reloading the standard set will not restore any created by either batch files or interactively in those instances, possibly causing malfunctioning of their currently running batch programs. OTOH, if you use only local functions and aliases, there will be none loaded before 4START/TCSTART is executed, so the unfunction and unalias commands are unnecessary. The exception is a pipe instance; if you use local functions/aliases your program will ensure that any functions or aliases defined in the parent instance after its xSTART command was executed are NOT propagated into the instance on the right side of the pipe. However, I do not recall a single instance in my many years of using 4DOS+ where I wanted that to happen.

BUG: You create an array _TCCInstnces correctly, but use unset instead of unsetarray.

Some other observations:

1/ 4EXIT/TCEXIT is the command automatically executed on command processor termination, NOT TCEND/4END.

2/ you did not report the command processor version where your TCSTART fails, but it is obviously designed for current and older versions.

3/ As Rex inferred, one of the alias files you load may change a command later in the batch file from being an internal command to an alias. I am sure you realize this can be easily avoided by using e.g. *function instead of function.

4/ You could use the single command for all command processor versions
if isinternal zip setdos /i-zip /i-unzip
(you can even drop the test, SETDOS does not detect an error when you attempt to disable a nonexisting command on the principle that it just did not need to do anything to achieve your goal).

5/ If any of the mapped drives are removable ones, or any of the systems on your network are removable (e.g., laptops), the drive remapping may be required when a command processor instance has previously been mapped already. There is a current thread in this Forum related to detecting disconnects that is still active.
Jun 3, 2008
Temecula, CA
Lots of good feedback. Hasn't solved my problem yet, though. :(

OK, I've incorporated lots of what you suggested.
  • I've been using 4nt version 6.01.245 since it first came out (and of course was using 4dos for years before that), but never upgraded beyond that version until this past month. I use TCC on my main development machine, but still have 4nt on all of my other build machines. I have tried to maintain compatibility with my aliases and functions between them wherever possible. The TCC version is 15.01.52, the latest available.
  • Kept the echo > ... stuff, but added a LOG statement at the beginning of the file. Strange, because no log file is getting created. Did I do it wrong?
  • I use local aliases. Sometimes different windows need different definitions, or I temporarily modify them. So that shouldn't be causing the problem.
  • I do use pipe operations. I'm not quite clear on the implications of local or not, but I've never in my many years of 4nt usage had a problem.
  • Fixed the UNSET versus UNSETARRAY, and the EXIT versus END strings in my comments. Good catches.
  • Updated the SETDOS to the simpler syntax.
  • The network drives are rather unreliable. Our network is horribly flaky, and sometimes I can see them, sometimes not. The thread that you mention in that regard - is that the one called "Handle unexpectedly inaccessible CWD"?
  • comspec environment variable is set to "C:\Program Files (x86)\JPSoft\TCMD\tcc.exe", in case that wasn't obvious.
  • [edit] I forgot to add that when those debugJP<letter>.txt files are created in the C:\WIP folder, I noticed that the contents of ...a and ...b had the single letter a and b, respectively (as expected), but ...c was a zero-byte file.
OK, I'll use the file upload method for my revamped (but still not fixed) tcstart.btm, and also my alias files.


  • tcstart.btm
    2.1 KB · Views: 73
  • MyStuff.zip
    12.1 KB · Views: 81
Similar threads
Thread starter Title Forum Replies Date
T Fixed Function @timer[] does not work as required Support 6
D Parsing an array variable to an array does not work Support 5
J Take command does not start on Windows 10 Support 3
J ffind does not find files Support 4
Joe Caverly PAUSE does not erase countdown timer Support 0
D ParentDirectory does not update directory history Support 6
D Documentation Help "Startup" page does not describe global lists Support 0
Charles Dye Does HASH's /E option do anything? Support 1
fishman@panix.com First TCC instantiation after reboot does not work. Support 17
D Fixed @VERSION does not increment pre-fixed version numbers. Support 1
vefatica Why does @WSLPATH double the leading '/'? Support 7
D What does the file "..\Everything\Run history.csv" store? Support 5
Peter Murschall WAD rem does not work correctly Support 8
vefatica Does @SYMLINK work? Support 6
R Tree on FAT32 does not sort by name by default. Support 6
A Tcc does not recognize "bcdedit" Support 20
MickeyF Why does this batch file give me 'unknown command "else"' error? Support 17
M Ctrl-C when using command line history does nothing Support 2
vefatica JOBS /K ... how does it work? Support 5
Joe Caverly Why does TCCRT return VIEW as an internal command? Support 6
D Does TCC improve CMD's implementation of ECHO? Support 6
vefatica Find Files/Text dialog: does it work? Support 0
Alpengreis [v22.00.41] sync command flag "/X" does not work Support 22
Joe Caverly .PS1 script does not work with PSHELL Support 11
M MOVE does not behaves like intended (on failure) Support 1
R Fixed Sendmail parameter /USER= does not work Support 4
twaterloo does tcc have a task sceduler Support 4
Brian Woodward How to? Does FTP.CFG only support SSL over port 21? (Newbie) Support 6
M Activation Key does not correspond… Support 2
James Miller tcc shell window does not disappear Support 18
D Lua does not work on the commandline Support 5
D Fresh instance of TCMD does not use TCMD.INI Support 7
D Fixed @Lua does not behave as documented Support 8
D everything /o does not open the option dialog Support 4
M Why does HELP keep opening in the background? Support 0
vefatica Does TCC know I'm visiting the forums? Support 76
vefatica Why does my forum theme keep changing? Support 1
fishman@panix.com 19.02.37 Does Not Install For Me Support 2
I Windows 10 console does not allow alt-F4 alias to complete Support 1
fromano WAD ver /r does not detect Win 10B10166 Support 5
Alpengreis Fixed BATCOMP /O does not work Support 1
D Fixed Cut and paste in TC's file/folder view does not remove file Support 17
E View (internal command) does nothing now Support 3
D How does Cut work? Support 8
B How to? why does my BTM stop Support 2
I "IF" command in a variable does not expand redirection variable name Support 0
samintz How to? What does ~ do? Support 1
C Msg Popup window does not close Support 8
D WAD Alt-Left doesn't work, but Alt-Shift-Left does Support 1
Joe Caverly @SCRIPT does not like all comments Support 2

Similar threads