C# How to make Total Commander execute a command?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Ivclim
Junior Member
Junior Member
Posts: 8
Joined: 2017-11-18, 19:47 UTC

C# How to make Total Commander execute a command?

Post by *Ivclim »

C#
How to make, that when Total is executed command is executed?

Code: Select all

string file = @"C:\Program Files (x86)\Total\Totalcmd.exe";         
Process.Start(file,@"OPENTABS \\Server\Total\tab_1_вклд.tab"); 
How to make that:
- Total Commander starts;
- Total Commander executed the command?
For example "OPENTABS"

The code does not work.

How to make it work?
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

F1 4.a Commandline parameters wrote:...
Drive:\Directory Loads the first directory passed to Total Commander into the left window, and the second into the right window. Directory names containing spaces must be put in double quotes! Always specify the full path name including the drive! To open a stored FTP connection, use FTPOPEN:stored_ftp_name as path. Also accepts shares in the form \\server\share\subdir or smb: //server/share/subdir
Instead of a directory, you can also pass a .tab file to load the saved tabs (replacing the current tabs).
HTH
Holger
Make our planet great again
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

HolgerK wrote:
F1 4.a Commandline parameters wrote:...
Drive:\Directory Loads the first directory passed to Total Commander into the left window, and the second into the right window. Directory names containing spaces must be put in double quotes! Always specify the full path name including the drive! To open a stored FTP connection, use FTPOPEN:stored_ftp_name as path. Also accepts shares in the form \\server\share\subdir or smb: //server/share/subdir
Instead of a directory, you can also pass a .tab file to load the saved tabs (replacing the current tabs).
HTH
Holger
Unfortunately TC crashes if I use tab files as parameter.

Total Commander has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

This tab files are loaded without problems from inside of TC with OPENTABS.
Here an example of such file:

[activetabs]
[inactivetabs]
0_path=C:\Tools\Wincmd\
0_options=1|3|1|0|0|0|0
activetab=0
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
Ivclim
Junior Member
Junior Member
Posts: 8
Joined: 2017-11-18, 19:47 UTC

Post by *Ivclim »

HolgerK wrote:
F1 4.a Commandline parameters wrote:...
Drive:\Directory Loads the first directory passed to Total Commander into the left window, and the second into the right window. Directory names containing spaces must be put in double quotes! Always specify the full path name including the drive! To open a stored FTP connection, use FTPOPEN:stored_ftp_name as path. Also accepts shares in the form \\server\share\subdir or smb: //server/share/subdir
Instead of a directory, you can also pass a .tab file to load the saved tabs (replacing the current tabs).
HTH
Holger
Thank you
could you write more in detail?
I try, something does not work out
User avatar
Dalai
Power Member
Power Member
Posts: 9386
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Horst.Epp wrote:Unfortunately TC crashes if I use tab files as parameter.
Yes, it seems there's a problem with this feature. With my regular wincmd.ini TC tries to load the specified .tab file as an archive. With a fresh wincmd.ini it works as expected. Currently, I'm trying to figure out which section the culprit is in.

[ADD]
The issue is somewhere in the [PackerPlugins] section.
[/ADD]

[ADD2]
It's the stalker.wcx packer plugin in my case:

Code: Select all

db0=448,%COMMANDER_PATH%\Plugins\stalker\stalker.wcx
When this line is either removed or commented out, TC opens the tabs in the .tab file as expected. If the line is there, TC tries to open the .tab file as archive. This is a bug.
[/ADD2]

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Horst.Epp wrote: Total Commander has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

This tab files are loaded without problems from inside of TC with OPENTABS.
Here an example of such file:

[activetabs]
[inactivetabs]
0_path=C:\Tools\Wincmd\
0_options=1|3|1|0|0|0|0
activetab=0
1. Bug report forum?
2. can't reproduce the crash. TC opens the bar file in active panel (as Dalai said, assuming an archive-file)
3. afaik you can't create such a tab-file without saving both sides and editing/removing the content of [activetabs] section. So what's your point:
- Something in TC does not act like you wan't after hacking tab files?
- Feature request: "Load Inactive Tabs"?

Regards
Holger
Make our planet great again
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Ivclim wrote:I try, something does not work out
Please explain in detail what you tried and what does not work.

Thanks
Holger
Make our planet great again
User avatar
Dalai
Power Member
Power Member
Posts: 9386
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

I opened a bug report TC tries to open .tab files as archive with packer plugin.

@Horst.Epp:
My guess is that you have some packer plugin installed that reacts worse to the attempt to open the .tab file as an archive. Try renaming the [PackerPlugins] section in your wincmd.ini or something like that.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ivclim
Junior Member
Junior Member
Posts: 8
Joined: 2017-11-18, 19:47 UTC

Post by *Ivclim »

The HELP says:
HolgerK wrote:
Also accepts shares in the form \\server\share\subdir wrote:

Instead of a directory, you can also pass a .tab file to load the saved tabs (replacing the current tabs).
HTH
Holger
If I understood correctly, then my code looks like

Code: Select all

string file = @ "C: \ Program Files (x86) \ Total \ Totalcmd.exe";
Process.Start (file, @ "OPENTABS \\ Server \ Total \ tab_1_add.tab");
As a result,
  - Total starts
  - Total opens the folder "\\ Server \ Total "
but the necessary tabs do not open.

The "OPENTABS \\ Server \ Total \ tab_1_initial.tab" command is not executed.

How to make the "Total" open with a set of tabs "\\ Server \ Total \ tab_1_add.tab"?
User avatar
Dalai
Power Member
Power Member
Posts: 9386
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

2Ivclim
Don't know C#, but the command line should look like this:

Code: Select all

totalcmd.exe \\Server\Total\tab_1_add.tab
You should try that on a CMD first. Oh, and TC 9.10 is the first version that supports that kind of feature.

I'm confident you know how to translate the command line to C#.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

2Ivclim
You did not read the help (F1) didn't you?

Your command line should look like one of these:

Code: Select all

Process.Start (file, @"\\Server\Total\tab_1_add.tab");

Code: Select all

Process.Start (file, @"/L=\\Server\Total\tab_1_add.tab");

Code: Select all

Process.Start (file, @"/R=\\Server\Total\tab_1_add.tab");
In addition you may have to quote the path if the path contains spaces:

Code: Select all

Process.Start (file, @"/R=""\\Server\Total Space\tab 1 add.tab""");
Regards
Holger

Edit: "OPENTABS:" sample removed (i thought it should work the same like "FTPOPEN:" but this seems to be not implemented...)
Edit2: replace backslash with correct slash for parameter "/L" and "/R"
Last edited by HolgerK on 2018-01-05, 19:27 UTC, edited 2 times in total.
Make our planet great again
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

HolgerK wrote:
Horst.Epp wrote: Total Commander has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

This tab files are loaded without problems from inside of TC with OPENTABS.
Here an example of such file:

[activetabs]
[inactivetabs]
0_path=C:\Tools\Wincmd\
0_options=1|3|1|0|0|0|0
activetab=0
1. Bug report forum?
2. can't reproduce the crash. TC opens the bar file in active panel (as Dalai said, assuming an archive-file)
3. afaik you can't create such a tab-file without saving both sides and editing/removing the content of [activetabs] section. So what's your point:
- Something in TC does not act like you wan't after hacking tab files?
- Feature request: "Load Inactive Tabs"?

Regard
Holger
I removed the active side because using such file as a auto-run in a view mode leads to an infinite TC loop if this view is started by Auto-switch.
The intention is to start several tabs in the inactive side when a certain dir is opened. But when this active dir is also in the tab file the Auto-run is started again and so on ...
I reported this problems long time ago but Christian refused to detect such condition.
It would simply requiring not to run an auto-run if the new dir is already the active one. I don't see any good reason why he refused such an easy change which prevents looping in TC. :(
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Horst.Epp wrote:The intention is to start several tabs in the inactive side when a certain dir is opened.
<OT> A command concatenation like

Code: Select all

cm_FocusTrg,em_loadTabsForTarget,cm_FocusTrg
wouldn't work as autorun command for view mode?
</OT>

Regards
Holger
Make our planet great again
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

Dalai wrote:I opened a bug report TC tries to open .tab files as archive with packer plugin.

@Horst.Epp:
My guess is that you have some packer plugin installed that reacts worse to the attempt to open the .tab file as an archive. Try renaming the [PackerPlugins] section in your wincmd.ini or something like that.

Regards
Dalai
I tested with an absolute fresh ini file and TC doesn't crash but show the content of the tab file like an archive.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

HolgerK wrote:
Horst.Epp wrote:The intention is to start several tabs in the inactive side when a certain dir is opened.
<OT> A command concatenation like

Code: Select all

cm_FocusTrg,em_loadTabsForTarget,cm_FocusTrg
wouldn't work as autorun command for view mode?
</OT>

Regards
Holger
That would lead to the same recursion problem if the tab file also contains the active side dir. Only removing the active dir from the tab file avoids TC loop.
Its currently no problem for me because I use this modified tab files from inside TC which gives no problems or crashes.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
Post Reply