1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to start new tcmd instance?

Discussion in 'T&T - Miscellaneous' started by John Daly, May 23, 2016.

  1. John Daly

    Joined:
    May 19, 2016
    Messages:
    5
    Likes Received:
    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.
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Sorry if I'm belaboring the obvious, but is the SingleInstance option set?
    Code:
    echo %@iniread[%_ininame,TakeCommand,SingleInstance]
    
     
  3. John Daly

    Joined:
    May 19, 2016
    Messages:
    5
    Likes Received:
    0
    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>
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    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
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,877
    Likes Received:
    30
    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.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,877
    Likes Received:
    30
    That starts multiple instances but doesn't run anything, apparently ignoring the parameters.
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,877
    Likes Received:
    30
    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 )
     
  8. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    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] )
     
  9. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    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".
     
    #9 MaartenG, Sep 11, 2016
    Last edited: Sep 11, 2016

Share This Page