Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to start new tcmd instance?

May
5
0
I want to start 3 instances of tcmd, each with 6 tabbed console windows running various things. I'm starting this from a cmd window. I have it working from a batch file like this:
start /B cmd /C "C:\Program Files\JPSoft\TCMD19_x64\tcmd.exe" /C %1 %2 %3 %4 %5 %6 %7 %8 %9
the arguments are a batch file + params that starts 6 command programs I run with /tab and they open as expected.
this almost works right - but the second time I run it with different parameters I want it to start in a new tcmd instance, what it does is add tabs to the current instance. I looked at the help and did some experiments, but no luck! I'm probably missing something obvious.
 
Sorry if I'm belaboring the obvious, but is the SingleInstance option set?
Code:
echo %@iniread[%_ininame,TakeCommand,SingleInstance]
 
Sorry if I'm belaboring the obvious, but is the SingleInstance option set?
Code:
echo %@iniread[%_ininame,TakeCommand,SingleInstance]

nope

TCC 19.10.51 x64 Windows 10 [Version 6.3.14349]
Copyright 2016 JP Software Inc. All Rights Reserved
Registered to John Daly - 1 System License

e:\xrs1606>echo %@iniread[%_ininame,TakeCommand,SingleInstance]
No

e:\xrs1606>
 
Try it without the /C:
start /B cmd /C "C:\Program Files\JPSoft\TCMD19_x64\tcmd.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
 
Read about the "/C" start-up option ... "If there is already a Take Command session running, /C creates a new tab in the existing Take Command rather than starting a new session.". That's what's biting you in spite of SingleInstance=No. Unfortunately. "/T" does the same thing. Perhaps Rex will change that behavior or provide a way to override it. Right now I can't think of a way that you can have all you want. I'll think about it during dinner.
 
Try it without the /C:
start /B cmd /C "C:\Program Files\JPSoft\TCMD19_x64\tcmd.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
That starts multiple instances but doesn't run anything, apparently ignoring the parameters.
 
This is a kludge but it worked to start three instances and have each run a batch file (the same batch file) in its default tab. Some kludge of this kludge might get you where you want to go.
Code:
do i=1 to 3 ( delay 1 & start g:\tc19\tcmd.exe & delay 2 & keystack "v:\speed.btm" Enter )
 
Regarding your option of starting TCMD 3 times with /T /C : You can see that the second TCMD gets started, but then the Tabs merge in the existing TCMD and the second TCMD closes itself. I don't think there's a way around that.
Maybe next solution will work? (not tested):

Why not create 3 seperate INI-files, each with your desired tabs and then start each TCMD with it's own INI-file?

You could create these pre-configured INI's on the fly with a .btm: (copy %_ININAME session1.ini), remove existing Tabs ( %@iniwrite[session1.ini,Tab1,,] ) and add the Tabs you want ( %@iniwrite[session1.ini,Tab1,Title,MyFirstTab] %@iniwrite[session1.ini,Command,Title,cmd.exe /k dir c:\temp] )
 
In the meantime I tested this (^) out. It will work.
That makes a more "quick and dirty" solution possible, that is based on the way INI files are parsed in TCMD: they are on a first come, first serve base. So color=red followed by color=orange will yield red.
With this "knowledge", one can do the following:
(As I said, a little bit "quick and dirty", but it does work (tested this time)):

StartTcmdSessions.btm
Code:
@echo off
setlocal

:::::::::::::: TCMD 1 ::::::::::::::

REM New INI file for this TCMD session
set SESS_INI=%temp%\session1.ini

REM Put Tab configuration in new INI file
TEXT > "%SESS_INI%"
;---------------------------------

[Tab1]
Title=MyFirstTab
Command=powershell.exe

[Tab2]
Title=MySecondTab
Command=cmd.exe /k dir c:\temp

;---------------------------------
ENDTEXT


REM Add the contents of the original TCMD.INI to the end of the new INI file
copy "%SESS_INI%" + "%_ININAME" "%SESS_INI%"

REM Start TCMD with this new, completed INI file
start TCMD.exe @"%SESS_INI%"



:::::::::::::: TCMD 2 ::::::::::::::

set SESS_INI=%temp%\session2.ini

TEXT > "%SESS_INI%"
;---------------------------------

[Tab1]
Title=Yet another Tab
Command=powershell.exe

[Tab2]
Title=What's in a name
Command=cmd.exe /k dir c:\temp

;---------------------------------
ENDTEXT


copy "%SESS_INI%" + "%_ININAME" "%SESS_INI%"
start TCMD.exe @"%SESS_INI%"



:::::::::::::: TCMD 3 ::::::::::::::

REM set .....

Assumption: You do'n't have extra [Tabx]'s in TCMD.ini beyond the [Tabx] you configure here.
So, if TCMD.ini contains [Tab3], it's content will get parsed and executed.

Further: you have to be aware that if you make changes that would normally end up in TCMD.INI now end up in SessionX.ini and those are session-based, not "sticky".
 
Last edited:
Back
Top