ToolBar Button Problem

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Dec 2, 2008
209
2
Canada
#1
TCC 15.00.36 Windows XP [Version 5.1.2600]
TCC Build 36 Windows XP Build 2600 Service Pack 3

I am trying to create a ToolBar Button but I seem to be having a problem and the error doesn't really help much.

Here is the button I am trying to add:

"Start a new window" selected
Button Label: Start MLSU
Tab Title: Start MLSU
Command: C:\Temp\Monitor-Load-Server-for-Updates.btm
Directory: C:\Temp

(no quotes are used in any of the dialog entries)


The error I get is an Error Dialog with:

"C:\Temp\Monitor-Load-Server-for-Updates.btm"

(quotes are part of the message displayed)

Finally the file, Monitor-Load-Server-for-Updates.btm does exist in C:\Temp.

Any ideas what I am doing wrong?

Craig
 
#2
I tried something similar and it worked. But (1) .BTM is associated (Windows) with TCC.EXE, and (2) TCMD's "Comspec" is set to TCC.EXE. You might try, as the command,
Code:
drive:\path\tcc.exe C:\Temp\Monitor-Load-Server-for-Updates.btm
But I have a question ... in my test, I specified "Start a new window" and my BTM (the command) started in a stand-alone console. I figured it would start in a new tab? How do you get a button to start something in a new tab?
 
Dec 2, 2008
209
2
Canada
#3
Here are all the possible settings for comspec

[C:\]set /u comspec
C:\Program Files\JPSoft\TCMD15\tcc.exe

[C:\]set /d comspec
C:\Program Files\JPSoft\TCMD15\tcc.exe

[C:\]set /s comspec
C:\Program Files\JPSoft\TCMD15\tcc.exe

[C:\]set /v comspec
C:\Program Files\JPSoft\TCMD15\tcc.exe

[C:\]set /e comspec
C:\Program Files\JPSoft\TCMD15\TCC.EXE

and the COMSPEC set in the option panel for TCMD is "C:\Program Files\JPSoft\TCMD15\tcc.exe" (including the quotes).

If I put the "drive:\path\tcc.exe" in front of the .BTM file it works, but if this is the case then using the "..." button at the "Command:" prompt shouldn't display ".BTM" as if they are valid.

I noticed something else, the documentation says "The command and directory fields can include environment variables and TCC internal variables and variable functions." but if I use "%jpb\test.btm" in the Command: area of my button, I get the error "The system cannot find the file specified. "\test.btm"", If I do a "set %jpb" it is defined. If I do a " set /u jpb="%USERPROFILE\My Documents\JPSoft\Batches" " and test the button I get the error "C:\Documents and Settings\cgunhouse\My Documents\JPSoft\Batches\test.btm". Now if I do "set /u jpb=" and try the button I still get the error "C:\Documents and Settings\cgunhouse\My Documents\JPSoft\Batches\test.btm" and not "The system cannot find the file specified. "\test.btm"". If I exit TCMD after the "set /u jpb=" I get the "The system cannot find the file specified. "\test.btm"" error again. My question here is where is the button getting it's environment variables from?

Craig
 
#4
TCMD looks in ITS OWN environment (which it gets at start-up from the system) for environment variables. If you have checked TCMD's "Update Environment on System Change" (Config TCMD\Advanced), your "SET /U ..." in TCC should propagate immediately to TCMD (I didn't test it).
 
Dec 2, 2008
209
2
Canada
#5
I do have "Update Environment on System Change" set.

Then "set /u jpb=" or "unset /u jpb" should unset %jpb for the button in TCMD but it doesn't seem to do that.

It also seem that the buttons can only use environment variables defined as system (/s), user (/u) and volitile (/v), while default (/d) and env vars (/e) seem to be ignored.
 
#6
I do have "Update Environment on System Change" set.

Then "set /u jpb=" or "unset /u jpb" should unset %jpb for the button in TCMD but it doesn't seem to do that.

It also seem that the buttons can only use environment variables defined as system (/s), user (/u) and volitile (/v), while default (/d) and env vars (/e) seem to be ignored.
Is that option set for TCMD? It does seem to be working. In the test below (using a plugin of mine) process 4980 is the TCMD in which TCC is running. When I "set /u bar=666" in TCC, TCMD updates its environment.
Code:
v:\> echo %@pset[4980,bar]
ECHO is OFF
 
v:\> set /u bar=666
 
v:\> echo %@pset[4980,bar]
666
Unsetting the variable doesn't propagate to TCMD (I don't know if it's supposed to).
Code:
v:\> unset /u bar
 
v:\> echo %@pset[4980,bar]
666
It's no surprise that /D and /E don't work (read about them).
 

rconn

Administrator
Staff member
May 14, 2008
10,099
85
#8
I do have "Update Environment on System Change" set.

Then "set /u jpb=" or "unset /u jpb" should unset %jpb for the button in TCMD but it doesn't seem to do that.
There are two places where you specify whether the environment gets updated on a system change. In TCMD, it's in Options / Configure Take Command. In TCC, it's in OPTION / Startup. If you want to change the TCMD environment (which tabs inherit), you have to set the TCMD option.

I just tested it here, and everything works as expected in v15 -- SET /U causes TCMD's environment to be reset, and is passed to new TCC tabs.

It also seem that the buttons can only use environment variables defined as system (/s), user (/u) and volitile (/v), while default (/d) and env vars (/e) seem to be ignored.
You cannot have TCMD (or any other app, unless you want to inject code into other processes) read a variable from another process and set it in its own environment, which is apparently what you're expecting to do with "/E". /E just means set a variable in the local TCC environment as well as in the registry.
 
Dec 2, 2008
209
2
Canada
#9
I created a button with the following:

1) Send to the current tab
2) Button Label: Test
3) Command: "echo %test" enter

Immediately after creating the button, from the currently running copy of TCC under a TCMD tab and from TCMD, I did the following:

1) Press the "Test" button, and the current tab response with:

Prompt> echo
ECHO is OFF

2) In the current TCC tab type "set /u test=1"

3) Press the "Test" button, and the current tab response with:

Prompt> echo 1
1

4) In the current TCC tab type "set /u test="

5) Press the "Test" button, and the current tab response with:

Prompt> echo 1
1

6) In the current TCC tab type "set /u test=2"

7) Press the "Test" button, and the current tab response with:

Prompt> echo 2
2

It seems that once an environment variable is set, TCMD sees all changes to it except for it removal, via "set /u test=" or "unset /u test". For "set /u test=" and "unset /u test" to work you have to exit TCMD completely and restart it.

Craig
 
#10
I believe that's the intended behavior. And, IIRC, when I objected to it some time back Rex gave pretty good reasons for it. I searched (briefly) and failed to find the thread where that discussion took place.
 

rconn

Administrator
Staff member
May 14, 2008
10,099
85
#11
It seems that once an environment variable is set, TCMD sees all changes to it except for it removal, via "set /u test=" or "unset /u test". For "set /u test=" and "unset /u test" to work you have to exit TCMD completely and restart it.
WAD.

You're looking at it as "one TCMD + one TCC" -- reflect on the more usual "one TCMD + many tab windows".

What happens is that TCMD is notified (by Windows, not by TCC) that some unidentified thing changed in the environment (not in the registry). TCMD has no idea what variable changed, or whether it's a local variable or one of the system registry variables. So TCMD enumerates the system, user, and volatile registry variable lists, and updates its local environment with the current value of each variable.

But TCMD doesn't know what to do with any variables that aren't in the registry -- for example, all of the local variables that are essential to TCMD's operation. Should it delete them all (and promptly blow up)? Should it delete variables that might have been deleted in one tab window but are critical in other tab windows? Should one ill-behaved app in one tab window be allowed to kill everybody else (including Take Command itself)? How should it handle dueling tab windows where one is adding and the other is deleting registry variables?

The reason "Update Environment on System Change" isn't the default is that (like having the folder / list view windows track the TCC current directory) it isn't nearly as good an idea as people first think.
 
#12
Good explanation! I think one of the OP's goals was to start a BTM in a new tab via a button. My experimentation suggested that the only way to do that was to specify "drive:\path\tcc.exe BTMfile" as the button's <command>. And I think the environment variable was an attempt to shorten that. Is there a built-in way to do it without without the whole TCC path (or without specifying TCC at all)?