How to? Pre-set _tcfolder on startup when Folders is set Auto-Hide

May 31, 2008
62
0
Oklahoma
Is there a way to pre-set _tcfolder by command before "unhiding" the "Folders" view if TCMD is started with the "Folders" view set to Auto-Hide?

I start TCMD with the "Folders" (and "List") view set to Auto-Hide. Since I want to have _tcfolder set to the current disk drive and directory on startup my tcstart.btm includes the following:
Code:
iff %_tctab == 1 then
  CDD /T %USERPROFILE%\Documents
else
  CDD %USERPROFILE%\Documents
endiff
Much to my chagrin this doesn't work and _tcfolder remains unset.
Code:
TCC  16.00.41 x64  Windows 7 [Version 6.1.7601]
Copyright 2014 JP Software Inc.  All Rights Reserved
Registered to "Me"
[C:\Users\rchapman\Documents]echo %_tcfolder
ECHO is OFF
C:\Users\rchapman\Documents]cdd /t .
[C:\Users\rchapman]echo %_tcfolder
ECHO is OFF
[C:\Users\rchapman]cdd /to .
C:\Users\rchapman]echo %_tcfolder
ECHO is OFF
And, it is not possible to set _tcfolder from the command line with either CDD /T or CDD /TO.

After "Folders" view is opened _tcfolder is immediately set to the directory specified by the "Start In" directory of the shortcut and from then on both CDD /T and CDD /TO work the way they should. i.e. they way I want them to ;)
Code:
C:\Users\rchapman\Documents]echo %_tcfolder
C:\Program Files\JPSoft\TCMD16x64
[C:\Users\rchapman]cdd /to .
[C:\Users\rchapman]echo %_tcfolder
C:\Users\rchapman
Is this WAD :( or am I missing something>
 
May 20, 2008
11,415
99
Syracuse, NY, USA
You can specify TCMD's startup directory in Options\TakeCommand\Advanced\StartFolder. That might work better.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Warning about using TCSTART to change TCC folders: it forces ALL instances of TCC to start there. When a TCC instance is on the right side of a pipe it generally expects to run in the folder of the left side.
 
May 31, 2008
62
0
Oklahoma
Warning about using TCSTART to change TCC folders: it forces ALL instances of TCC to start there. When a TCC instance is on the right side of a pipe it generally expects to run in the folder of the left side.
Thanks for the reply Steve and the excellent reminder. My tcstart.btm conforms to the recommendation in the Help for TCSTART well before any folder change.
Code:
:: Exit if running in a pipe or transient process
if %_pipe != 0 .or. %_transient != 0 quit
 
May 31, 2008
62
0
Oklahoma
You can specify TCMD's startup directory in Options\TakeCommand\Advanced\StartFolder. That might work better.
Vince thanks for the reply. However -
  1. It appears that environment variables (like USERPROFILE) don't work in the Advanced Options Start Folder field so I can't use %USERPROFILE%\Documents there.
  2. When the Start Folder field is set to the full path (e.g. C:\Users\rchapman\Documents instead of %USERPROFILE%\Documents) then _tcfolder is still unset on startup and can not be set by CDD /T or CDD /TO until the first time the "Folders" view is opened.
 
May 20, 2008
11,415
99
Syracuse, NY, USA
I don't know if this is an X64 bug, but, with Win7/32, I put this in my TCSTART.BTM:
Code:
echo _TCFOLDER = %_tcfolder
And when I start TakeCommand, I get the correct message in the TCC tab regardless of how TC's startup directory is specified (shortcut, option, or the default).
Then I put this in TCSTART.BTM:
Code:
echo tcfolder = %_tcfolder
cdd /t g:\
echo tcfolder = %_tcfolder
And when I started TakeCommand, the TCC tab showed
Code:
tcfolder = V:\
tcfolder = G:\
and the two explorer panes showed G:\ as expected.
IMHO, TCMD's startup directory option should expand environment variables.
Steve's right. You shouldn't CD or CDD in TCSTART.BTM (unless it's highly qualified).
 
May 31, 2008
62
0
Oklahoma
I don't know if this is an X64 bug, but, with Win7/32, I put this in my TCSTART.BTM: . . .
Thanks for the reply Vince. I don't have an installed TCC 16.00.41 32bit version available (and really don't have time for a dual installation on this machine ;)) but _tcfolder exhibits the same performance as indicated in my original post under both TCC 15.01.58 x64 Windows 7 and TCC 15.01.58 Windows XP using essentially the same tcstart.btm so perhaps there is some other factor involved.
Steve's right. You shouldn't CD or CDD in TCSTART.BTM (unless it's highly qualified).
Both Steve and your point is well taken but I am content to go with the work around provided in the TCSTART and TCEXIT help page:
You can work around these potential problems with the IF or IFF commands and the _PIPE and _TRANSIENT internal variables. For example, to skip all TCSTART processing when running in a pipe or in a transient session, you could use a command like this at the beginning of TCSTART:

if %_pipe != 0 .or. %_transient != 0 quit
 
Similar threads
Thread starter Title Forum Replies Date
D Fixed @VERSION does not increment pre-fixed version numbers. Support 1
V Set path permanently from within TCC? Support 3
S Debugger keeps breaking with no break point set. Support 1
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
R How to? Set default application in a special folder Support 4
A How to? Set up SMTP password in TCC-RT Support 1
vefatica WAD More SET /A woes Support 4
vefatica SET /A and multidimensional array. Support 1
M How to set Path variable for non-executable file extensions in 4DOS Support 8
D Need to set Take Command font size when switching to high DPI display Support 0
P "Set" command behavior - a bug? Support 3
M How to? Set the ribbon titles to mixed case Support 1
X How to set %_INIREAD result to variable Support 5
M WAD Set statements in () causes problems Support 8
M How to? How to set a default TITLE for newly opened tab? Support 2
M Fixed Set "VAR=VAL" format causes problems Support 12
vefatica SET /A var=expression=digits Support 3
cxxl Set encoding for batch file Support 4
B TCC 21.01.50 Problem with ALIAS /r and SET /r Support 2
vefatica SET /A var\=...? Support 10
dcantor Documentation SET /T: missing from heading Support 0
fpefpe Documentation Set /v Support 4
vefatica What's SET /Z? Support 1
R Fixed set /r has stopped working in build 35 Support 4
BeechComer Debugger: how to set %1 variable? Support 3
fpefpe How to? Global variable set /v Support 4
fpefpe Documentation Can the title line of tcmd be set? Support 4
J How to set working directory Support 10
Jay Sage Failure of ACTIVATE to Set a Window Position Support 3
rps Fixed Win "set /p" not working in V17 build 53 Support 3
vefatica SET /A "var%=N", TCC vs. CMD Support 0
J Set environment variable from stdout of command Support 3
Dan Glynhampton Fixed @version "force" flag not working, and unable to set separator Support 3
R WAD /= size ranges not set correctly Support 5
S How to? Set the timestamp of ZIP command built archive to match latest member Support 8
Mordachai Help! How to set parameters for script I'm debugging?! Support 6
Roedy SET= Support 2
A How to? Set up a log file for all command output Support 3
M Fixed character set in dir/copy Support 3
Phileosophos Fixed TakeCommand exits upon "set [" command Support 14
R How to set comspec to point to cmd.exe? Support 5
S WAD SET problem - array element initialization Support 11
C Wildcard expansion in FOR set Support 27
vefatica SET question Support 16
T Set 1% then Echo 1% Support 9
S SET /A question; HELP nits Support 8
noahcoad copy /w to FTP does not set time stamp Support 1
M A request for a new feature for the "set" command... Support 5
cgunhouse Accessing variables set using SET /U or SET /S Support 3
D Force For to treat set of values as text, not files Support 3

Similar threads