How to? Bat Works but BTM Doesn't

Nov 18, 2014
6
0
Can anyone help me understand why?

The purpose is to fix the taskbar that won't hide in Win7. Here's the code

g:\utils\pstools\pskill explorer.exe
start explorer.exe
exit

I'm running TCMD16
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
Is it possible that you're restarting Explorer before it is finished shutting down? You might try putting a DELAY 2 after the PSKILL. (And you could probably replace the PSKILL with a TASKEND /F.)
 
.BAT and .CMD script files are read line by line, with the file being closed and reopened each time (this allows for the now-obscure feature of self-rewriting scripts, and in the Dos/Command.com days allowed installing TSRs), while .BTM script files are read once into memory (BTM stands for "Batch To Memory; TCC still has to old LoadBtm command). This yields a difference in speed, which could explain the difference in behavior, because, as Charles Dye points out, the process may not have disappeared completely from the system at the time PsKill returns.
 
Nov 18, 2014
6
0
.BAT and .CMD script files are read line by line, with the file being closed and reopened each time (this allows for the now-obscure feature of self-rewriting scripts, and in the Dos/Command.com days allowed installing TSRs), while .BTM script files are read once into memory (BTM stands for "Batch To Memory; TCC still has to old LoadBtm command). This yields a difference in speed, which could explain the difference in behavior, because, as Charles Dye points out, the process may not have disappeared completely from the system at the time PsKill returns.

I have the btm file on my desktop. It works under these conditions 1) if I open a tcmd window and then run the btm from the commandline or 2)if I right click the icon and select open with TCC. If I just click on the btm or right click and select open with TCMD, , TCMD opens , and stays open. The btm does not run. I've added delays and echo statements, so I'm sure it does not run.
 
The issue seems to be related to the way you execute it, not to the contents of the script. Your original title stated there was a difference between .BAT and .BTM scripts, but you are not talking about it anymore.
The script has to be eventually executed by TCC (the console and interpreter). This is what happens with (1) and (2).
Unfortunately I am not used to the other methods. I never installed the file association with tcmdbatch.btm (which seems to associate script files with: "[path]\tcmd.exe" /c). If you run by (double-)clicking, the execution should be triggered by the Windows associations (check with the ASSOC and FTYPE commands). I don't understand where the "right click and select open with TCMD" can come from; has this been installed from something delivered by JP Soft, or did you choose TCMD in the "Select a program to open this file" dialog (I get this dialog if I run in TCC: "[path]\tcmd.exe/c somescript.btm)? In the latter case, it would sound as if you wrongly selected TCMD (the graphical interface that displays a console (TCC or any other console) in a tabbed Window) and not TCC. There are so many ways to configure the file associations…
When I want to have TCMD open and execute a script, I create a shortcut with a target in the form: "[path]\tcmd.exe" /t "[path]\tcc.exe" /k myscript.btm, i-e I specify both TCMD and TCC.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
I have the btm file on my desktop. It works under these conditions 1) if I open a tcmd window and then run the btm from the commandline or 2)if I right click the icon and select open with TCC. If I just click on the btm or right click and select open with TCMD, , TCMD opens , and stays open. The btm does not run. I've added delays and echo statements, so I'm sure it does not run.

I don't think that anything Rex provides, creates an "Open with TCMD" shell verb. It would be interesting to know (a) where that verb came from, and (b) what its contents are. Would probably take some digging through your registry to figure it out.

It might have been created by Explorer: http://technet.microsoft.com/en-us/magazine/ee851670.aspx
If that's where it came from, this shell verb just passes the filename of the batch file to TCMD.EXE without any further options -- and it will certainly be useless.
 
Coming back to the original problem: "BAT Works but BTM Doesn't".
When you (double-)click on a .BAT file, or when you select OPEN from the right-click menu, it is passed to CMD for execution. This is Windows standard and obviously works.
You probably tried to create the association for .BTM files, but directed it to TCMD. This does not work, but it should work if you direct to TCC, or (according to what I see in tcmdbatch.btm) if you manage to add a /C option for TCMD.
Personally I try and avoid these associations: they are system-wide, and too concealed. It is difficult to revert or to edit something once the association is made. Unless you take special steps (e-g setting up a version-independent junction to the directory), the association will point to a specific version (e-g "C:\Program Files\JPSoft\TCMD16x64\tcmd.exe").
I prefer setting up shortcuts individually on a file by file basis.
Concerning your specific file (pskill+start explorer): no part of it requires TCC, you can give it a .BAT extension and have it executed by CMD.
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly .BAT works in TCC-RT 25, but not in TCC-RT 26 Support 4
C .bat files works in cmd.exe, not in TCMD Support 6
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
I BTM slower than BAT? Support 14
S incorrect message at start Cancel batch job 4START.bat ? (Y/N/A) : Support 1
S Debugger Bat file call history Support 9
E How to? use Executable Extensions: .bat and .cmd Support 8
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10
C Documentation .CMD .BAT .BTM Support 15
w_krieger WAD 4DOS and benny.bat Support 2
A Stupid, obvious question - launch a BAT with TC Support 10
Mordachai How to get a TC interface instead of a console for .btm, .bat, ? Support 10
A WAD BOM printed on command line from BAT file Support 5
C Simple .bat question - dump contents of 2 dimensional array Support 2
CWBillow TCC and CMD / BAT files Support 3
C .CMD .vs. .BAT Support 3
B Strange handling of a .BAT file Support 5
Roedy bat file properties Support 1
T VIEW only works from command line Support 14
D Alias with setdos no longer works Support 21
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
Phileosophos Enumshares works sometimes Support 16
I findstr works in cmd but not in tcc Support 5
Dmitry L. Kobyakov WAD Start /pgm "name.htm" works improperly Support 4
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
Joe Caverly Works in debugger, not from cmd line Support 1
M "less" program that works in TC 18 Support 12
Joe Caverly Echo message works without the space? Support 3
cxxl dir /s works in mysterious ways :( Support 4
J WAD setarray "/f" only works on first one Support 1
M Console-Mode (*.exe) works in TCC, not in TCMD Support 2
redwdc btm won't run in ver. 17 but works in ver. 16 Support 11
vefatica Alias works differenltly v16 vs. v17 Support 13
C FFind /w works but FFind /= doesn't? Support 2
R Drag to BTM no longer works in Windows 8.1 Support 10
Frank @replace works case sensitive Support 5
D TPIPE works without being in path, but not V; aemail Support 8
noahcoad c:/hello.txt works in cmd.exe but not tcc.exe Support 1
K Ctrl-D alias no longer works Support 4
R %+ works differently after upgrade Support 3
Joe Caverly Clearing a section of the screen works in CMD, not in TC Support 2
MickeyF equivalent to TCSTART.btm for TCMD? Support 4
vefatica Console not redrawn in BTM or with multiple commands Support 4
Joe Caverly Embedding an .EXE (or other file) into a .BTM Support 8
Charles S. Roaten Problems with TCSTART.BTM Support 1
P Kill all other instances of tcc from a btm batch file Support 2
C TCC 26 BATCOMP BTM problems? Support 5

Similar threads