2

I want to create a BATCH file, which opens a specified folder with Total Commander. But there are 2 possibility:

  1. if there is no running TotalCommander --> a new TotalCommander will start and open the folder
  2. if there is an already running TotalCommander --> open the folder with the running TC, and do not start a new TotalCommander

I have a code, which opens the folder with TotalCommander, but it always start a new TotalCommander, and not using the running one:

@echo off
SET totalc="C:\totalcmd\TOTALCMD.EXE"
set folder="C:\temp"
ECHO opening %folder% with %totalc%
%totalc% %folder%
ECHO opened

Is there any solution, to resolve this?

victorio
  • 6,224
  • 24
  • 77
  • 113

1 Answers1

10
@echo off
    setlocal
    set "totalc=C:\totalcmd\TOTALCMD.EXE"
    set "folder=C:\temp"
    echo opening "%folder%" with "%totalc%"
    "%totalc%" /O /T /R="%folder%"
    echo opened

From the documentation

/O If Total Commander is already running, activate it and pass the path(s) in the command line to that instance (overrides the settings in the configuration dialog to have multiple windows)

/R= Set path right window

/T Opens the passed dir(s) in new tab(s) (for usage with /O)

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • excellent! I will drink a pálinka tonight to your health! en.wikipedia.org/wiki/P%C3%A1linka – victorio Oct 21 '14 at 10:01
  • when I'm trying to run this form `.bash_profile` script or from `git bash cli` - it opens new window, from `.bat` works like a charm, do you have any idea why is this happens? my command is ` c:\\totalcmd\\TOTALCMD64.EXE /O /T /S /L=c:\\users\\` – godblessstrawberry May 10 '18 at 15:08
  • works as charm with dashed params c:\\totalcmd\\TOTALCMD64.EXE -o -t -s -l=c:\\users\` – godblessstrawberry May 11 '18 at 08:21