Command line variable in tcstart.btm?

Jul 7, 2008
35
0
Texas, USA
Is there a way to to get the command line variable "%L" (set when "TCMD Prompt Here" is selected, as defined by tcmdhere.btm) in tcstart.btm?

I'd like to add some conditional functionality in tcstart.btm based on whether a startup directory was requested or not.

Thanks!
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,423
85
Albuquerque, NM
prospero.unm.edu
Is there a way to to get the command line variable "%L" (set when "TCMD Prompt Here" is selected, as defined by tcmdhere.btm) in tcstart.btm?

I'd like to add some conditional functionality in tcstart.btm based on whether a startup directory was requested or not.

It looks like that parameter is being handed to TCMD.EXE, not TCC.EXE, which makes it kinda difficult.... You can retrieve the command line originally used to start Take Command with something like

Code:
echo %@pidcommand[%@pid[tcmd.exe]]

but that probably won't be useful if you have SingleInstance turned on, and you used "TCMD prompt here" to launch a second instance of Take Command.
 
Jul 7, 2008
35
0
Texas, USA
Code:
echo %@pidcommand[%@pid[tcmd.exe]]

but that probably won't be useful if you have SingleInstance turned on, and you used "TCMD prompt here" to launch a second instance of Take Command.
I don't use SingleInstance (i.e. multiple instances are allowed), so that would work. It does seem to transit the parameters TCMD.EXE was launched with. But when launching a second instance, the parameters from the first instance are still in effect. Can that be avoided so that each instance would have the launch parameters from the associated TCMD.EXE?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,423
85
Albuquerque, NM
prospero.unm.edu
I don't use SingleInstance (i.e. multiple instances are allowed), so that would work. It does seem to transit the parameters TCMD.EXE was launched with. But when launching a second instance, the parameters from the first instance are still in effect. Can that be avoided so that each instance would have the launch parameters from the associated TCMD.EXE?

You might try %@PIDCOMMAND[%_PPID]

It would be a good idea to check that the first word of the return value does refer to TCMD.EXE, since TCC.EXE can be started by other programs such as Explorer.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
I suppose you could also edit the "here" command in the registry ... make it
something like

tcmd.exe /t tcc.exe cdd foo

Then TCC should see the startup command. With "SingleInstance" and an
already-running TCMD, that might be what you want (a new tab in the named
place). Without "SingleInstance" you'll get a new instance. Either way, and
unfortunately, a newly-created TCMD will also have the default tabs.

Rex, there should be a way to start TCMD for a specific purpose (as with /t
command) and **not** also get the default tabs (/O(nly) command?).
--
- Vince
 
Jul 7, 2008
35
0
Texas, USA
You might try %@PIDCOMMAND[%_PPID]
This seems to be working for what I'm looking to do. Basically I want to set prompt to Desktop unless a directory is requested when TCMD is being invoked. Multiple instances are allowed.

In tcstart.btm I have:

Code:
@ECHO OFF
prompt = $e[30;46;2m[$w]$e[40;36;1m$s[$t$h$h$h]#$e[40;37;2m$s
alias /R "c:\Users\Ville\My Documents\TCMD\aliases.tcmd"

path %path;%ProgramFiles(x86)\bind\

set startcommand=%@pidcommand[%_PPID]
set startdir=%@TRIM[%@word[2,%startcommand]]

msgbox ok "startcomand" startcommand is '%startcommand'
msgbox ok "startdir" startdir is '%startdir'

if %startdir == "" cdd desk:
cdd /to .

cls

Now this works in all cases except when I'm invoking TCMD from Launchy. It doesn't provide any command line parameters; startdir is empty (''), but still cdd desk: is not called, and since no command line directory is requested, TCC opens in c:\Program Files (x86)\TCMD\

Any idea why if %startdir == "" cdd desk: fails when startdir is blank, but only when started from Launchy? I tried to check it also with DEFINED, but it didn't help (I suppose it's always set since I use set startdir= ...).

Contents of startcommand and startdir are identical whether started from the Start menu icon or from Launchy, but the end result is different. :confused:

I'm using cdd /to . in the end because when the directory is requested (when selecting "TCMD prompt here"), the correct folder is highlighted in the GUI, but it may not be scrolled in the view if the current directory listing is long.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
On Tue, 04 May 2010 02:12:19 -0400, Ville <> wrote:

|Any idea why *if %startdir == "" cdd desk:* fails when startdir is blank,

You need the quotes:

*if "%startdir" == ""

You could also use:

if defined startdir ...
--
- Vince
 
Similar threads
Thread starter Title Forum Replies Date
nikbackm Command line evaluation question - variable inside parenthesis Support 7
vefatica `Back quotes` - command line vs. batch file Support 5
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 7
Phileosophos Command-line Editing Shortkeys That Fail Support 6
D Open Windows 10 Photos app from command line Support 11
fpefpe How to? command echo in title line/bar Support 2
vefatica Command line DO with no closing parenthesis? Support 9
R Long commands retrieved from command history have blank line when wrapped Support 20
D Double Quote in TC Tool Bar Button Command line Support 3
Joe Caverly Expand all aliases on the command line Support 2
Jay Sage Cannot Postion Cursor in Command Line Using Mouse Support 7
vefatica IDE.EXE's command line? Support 19
D btm file command line augments comparing for string or math. Support 12
P Escape key no longer clears command line in v24 Support 21
J File explorer handling from command line? Support 2
M Ctrl-C when using command line history does nothing Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
C Replace 1st argument on command line Support 4
K Command Line Selection Not Working Support 12
J Error running Python at command line Support 9
rps How to? Alias/Command line use of *log on/off Support 2
x13 //directive ignored on TCC command-line Support 4
J How to? max. practical command line length? Support 3
mfarah WAD Odd behaviour with command-line arguments on TCMD. Support 7
thorntonpg F1 on command line The webpage cannot be found Support 5
J Python: TCC command line parsing removes '=' equal sign characters Support 4
L Fixed console line length in Take Command 19? Support 3
C LOG entry for TCMD/TCC command line Support 15
H command line parsing question Support 5
Joe Caverly How to? Date Range in command line for 7zip /= Support 1
cgunhouse One of the Focuses of V17 Beta Testing Should Be Command Line Parsing Support 1
cgunhouse Jabber Command Line Option Being Transmitted -- Fixed with Build 42 Support 2
M Hotkey-mechanism, for doing something with the current command-line Support 4
J Passing % character through command line to .btm Support 5
vefatica Command line SETLOCAL? Support 11
tmaynard How to? Control-U alias for Escape (command line editing) Support 5
BobK How to? Handling filenames with blanks at command line Support 3
CWBillow Send Command-line with prompt? Support 6
M Missing PERL command-line arguments Support 1
fpefpe WAD Python support does not process command line Support 14
vefatica SENDMAIL, command line override SMTP server? Support 2
vefatica (OT) Show desktop from command line? Support 20
M Starting Windows GUI programs from the command line... Support 10
A How to? Remove last argument on command line Support 4
nickles Reload tcmd.ini from the command line Support 11
A How to? Invoke View Clipboard from command line Support 8
ehab aboudaya How to? activate tab with same directory in command line Support 6
A minor documentation fix - command line editing Support 0
A Minor documentation fix ["-" on command line] Support 3
A WAD BOM printed on command line from BAT file Support 5

Similar threads