FAQs: Button - How to execute more than one command at once

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
User avatar
Power Member
Power Member
Posts: 3067
Joined: 2007-09-13, 22:20 UTC
Location: Europa

FAQs: Button - How to execute more than one command at once

Post by *Stefan2 »

How-to execute more than one command at once

First, you can utilize the default MS-Dos command line syntax, like:

Command: [ cmd /c start X:\NirSoftLauncher\NirSoft\cports.chm && start X:\NirSoftLauncher\NirSoft\cports.exe  ]
Start path:
Tooltip: Launch two commands.

cmd /c >> invoke the command line processor to do something, and terminate it immediately if done. (opposite of cmd /k)
start >> execute the following command in a new process, so the cmd process is no longer need.
&& >> concatenate two commands. The && command separator performs error checking.
If the command to the left of the && command does not return the expected results, the commands to the right of the && command do not run.
& >> concatenate two commands.
The single & command separator is not perform a error checking and all commands run.

Type 'cmd /?' and 'start /?' in a command line window (DOS-Box) to get more help.

- - -

Then you can just launch a Batch file, which contains all your commands.

Command: [ X:\NirSoftLauncher\NirSoft\Launchy.cmd ]
Start path:
Tooltip: Launch my batch.


Code: Select all

start h:\a\NirSoftLauncher\NirSoft\cports.chm 
start h:\a\NirSoftLauncher\NirSoft\cports.exe

- - -

Internal solution > Button bar multiple commands
19.02.14 Release Total Commander 8.50 final (32/64)

Added: Support for multiple internal (cm_xyz) or user-defined (em_xyz) commands
on a single button or start menu command: Separate by a comma, e.g. cm_SelectAll,cm_Copy.

Not all commands can be chained this way!

- - -

Example of adding multiple commands to the button bar:

Command: cm_About,cm_HelpIndex,cm_FtpConnect

Note: currently there are no space allowed. Space will work for CM_cmds, but fail for EM_cmds.
Wrong Command: cm_About ,  cm_HelpIndex,  cm_FtpConnect

To lookup the internal CM_commands take a look at the "TOTALCMD.INC" file in the TC folder:

cm_SelectFiles=3312;Select group: just files
cm_SelectFolders=3313;Select group: just folders
cm_SaveSelectionToFile=2031;Save file selection to file
cm_LoadSelectionFromClip=2033;Read file selection from clipboard

Or type "cm_CommandBrowser" into the TC command line box.

- - -

To add your own commands,

first create them as EM_commands in usercmd.ini.

(If you have no usercmd.ini, just create a plain text file in TC folder)


Code: Select all

menu=Show Total Commander Folder

cmd=cd *.exe *.cmd *.bat *.com *.vbs *.ps1
Then add them to an button as shown above.
Command: em_CD_commanderpath,em_show_executables,cm_HelpIndex

- - -

You can also use the GUI to modify the usercmd.ini:

To start, choose either

Start > Change Start Menu... > Add Item... > [insert a title]+[OK]


Right click at Button Bar > Change... > Add > (be sure to add a icon too, e.g. %Commander_Path%\WCMICONS.DLL)

Next to create a new EM_command
> click at the loupe symbol button
> choose Category "usercmd.ini" > New... > [insert a name like "em_MyCmd"]
> add your command and parameter (e.g.: "cmd /k cd %Commander_Path%")
> [OK] several times


- - -

Some simple commands for testing:


Code: Select all



- - -

If you need a pause between two commands, there is no internal solution right now.
All commands are fired up nearly the same time.
If you want to have a break, use a script or batch, and send TC command via 'NIRSOFT sendmsg' (see below).
In such script you are able to add a wait command.

- - -

Remember: you can always press the F1 key to get context sensitive help.
And, there can already many post about this task be found in the forum.


External solution >

>> http://www.ghisler.ch/wiki/index.php/AutoHotkey:_Send_a_command_to_Total_Commander

>> http://en.totalcmd.pl/download/add/Add/TC_Multiple_Commands

Code: Select all

REM TC_Multiple_Commands (TCMC)
REM http://en.totalcmd.pl/download/add/Add/TC_Multiple_Commands

REM TCMC.exe [delay] params
REM Delay - delay (in ms) between sending each command, default 0.
REM Each parameter has to start with 2 letters that specify message type.
REM CM for internal commands (cm_SrcShort etc.) and 
REM EM for external ones (em_something).
REM Then comes parameter. 
REM See TotalCmd\usercmd.ini for your own external commands.
REM Example: usercmd.ini
REM cmd=%comspec% /c copy nul
REM Param=?%%Date:~-4,4%%.%%Date:~-7,2%%.%%Date:~0,2%%.txt
REM For internal commands you can 
REM write number that represents it: (for cm_SrcShort: CM301) 
REM or it's name - (CMcm_SrcShort).
REM See TotalCmd\TOTALCMD.INC for internal commands, like
REM cm_HelpIndex=610;Help index
REM cm_Keyboard=620;Keyboard help
REM cm_About=690;Help/About Total Commander

ECHO execute internal command "690"
tcmc CM690

ECHO execute internal command "cm_About"
tcmc CMcm_About

ECHO execute external command "em_NewFile_YYYYMMDD"
tcmc EMem_NewFile_YYYYMMDD

ECHO All done!

- - -

NIRSOFT sendmsg

SET nirc=%Commander_Path%\TOOLs\NirSoft\nircmdc.exe
REM cm_LoadSelectionFromClip 2033
%nirc% win sendmsg class TTOTAL_CMD 1075, 2033, 0

REM invert the selection, select file there name are not in clipboard:
REM cm_ExchangeSelection 525
%nirc% win sendmsg class TTOTAL_CMD 1075, 525, 0

- - -
MVVs' TCFS2 + TCFS2Tools

TCFS2 features:
+ maximize/restore window
+ move/resize window
+ hide/show window title
+ enable topmost window mode
+ hide/show any TC interface item
+ change dirs in panels
+ move file panels separator
+ send keypresses
+ undo last action using backup command
+ etc...

TCFS2Tools features:
+ show/hide main menu
+ temporary show main menu on menu call
+ show main menu as popup menu on user command
+ get/set file panel separator
+ get current view modes for panels
+ get system metrics via function GetSystemMetrics
+ get width and height of desktop work area

- - -

Samuels' ButtonBar eXtended


+ Create buttons that run macros (of TC commands and/or program calls)
+ Buttons can run different commands if you hold down modifier keys like Ctrl, Alt and Shift. Its also possibly to use mouse buttons as modifiers.
+ Integration into TCs buttonbar.

- - -

....to be continued:

List2multiInstance\ --- start application and pass multiple files.
List2Run\ --- start application and pass multiple files.
lst2clip\ --- take selection, [modify it], pass to clipboard.
lst2str\ --- start application and pass multiple files.
SplitP1\ --- splits a pathfilename and pass the wanted part to next program.
TCBL\ --- Build and launch a bat script with commands for each file present in the ListFile.
TCCP\ --- Total Commander Command Poster - send PostMessage.
TCMC\ --- TC Multiple Commands - send PostMessage.
\wdx\script\ --- Plugin allows to write your own vbs and js scripts.

- - -

Finde mich: mehrere Befehle ausführen eine Art "Befehle-Set" auf einen Button legen?
Find me: One button two commands multiple commands button bar more commands buttonbar own commands button

Last edited by Stefan2 on 2015-05-07, 06:18 UTC, edited 8 times in total.
Post Reply