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

English support forum

Moderators: Stefan2, white, sheep, Hacker

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

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

Post by *Stefan2 » 2014-08-25, 10:28 UTC

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  ]
Parameters:
Start path:
Icon file: %COMMANDER_PATH%\TOTALCMD.EXE
Icon:
Tooltip: Launch two commands.

Explanation:
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 ]
Parameters:
Start path:
Icon file: %COMMANDER_PATH%\TOTALCMD.EXE
Icon:
Tooltip: Launch my batch.

Launchy.cmd

Code: Select all

@ECHO OFF
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!
(32/64)

- - -


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:

Examples:
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)


\usercmd.ini

Code: Select all

[em_CD_commanderpath]
cmd=cd %COMMANDER_PATH%
menu=Show Total Commander Folder

[em_show_executables]
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]

or

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

Done.


- - -


Some simple commands for testing:

\usercmd.ini

Code: Select all

[em_OpenDosBox]
cmd=cmd

[em_OpenExplorer]
cmd=explorer

- - -


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://ghisler.ch/board/viewtopic.php?t=14364

>> 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

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

REM TCMC.exe [delay] params
REM 
REM Delay - delay (in ms) between sending each command, default 0.
REM 
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 
REM See TotalCmd\usercmd.ini for your own external commands.
REM Example: usercmd.ini
REM [em_NewFile_YYYYMMDD]
REM cmd=%comspec% /c copy nul
REM Param=?%%Date:~-4,4%%.%%Date:~-7,2%%.%%Date:~0,2%%.txt
REM
REM For internal commands you can 
REM write number that represents it: (for cm_SrcShort: CM301) 
REM or it's name - (CMcm_SrcShort).
REM 
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!
PAUSE

- - -


NIRSOFT sendmsg
http://ghisler.ch/board/viewtopic.php?t=40440

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
http://ghisler.ch/board/viewtopic.php?t=29700

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
http://www.ghisler.ch/board/viewtopic.php?t=20274

Features:

+ 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.
PowerShell
PowerPro


- - -



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.
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

Post Reply