Page 1 of 5

Can you add a cm command to restart TC?

Posted: 2022-09-07, 16:27 UTC
by ruizrzr1
I usually use tcimg to restart TC, but sometimes it will not start after TC is closed.

Re: Can you add a cm command to restart TC?

Posted: 2022-09-07, 17:47 UTC
by petermad
I have these commands in my usercmd.ini file:

Code: Select all

[em_newcommander]
cmd=%COMSPEC% /C
param=%Z%X start "" "%%COMMANDER_EXE%%" /N /P /A /i="%%COMMANDER_INI%%" %P%N* %T%M*
menu=Open new instance of Total Commander with current directories
button=%COMMANDER_EXE%
iconic=1

[em_restartcommander]
cmd=em_newcommander, cm_Exit
button=%COMMANDER_EXE%
menu=Restart Total Commander  with current directories
button=%COMMANDER_EXE%
then I can user either of the two em commands in Buttonbar, Keyboard shortcuts, Main Menu, Start Menu or Directory Hotlist

Re: Can you add a cm command to restart TC?

Posted: 2022-09-07, 18:20 UTC
by Sir_SiLvA
petermad wrote: 2022-09-07, 17:47 UTC then I can user either of the two em commands in Buttonbar, Keyboard shortcuts, Main Menu, Start Menu or Directory Hotlist
THANK you very much for this :!:
I have been using ReloadTC till now which never worked for tc64 but this is perfect.
(PS: is there anyway to make TC load usercmd.ini from a userdefined folder like %Commander_Path%\Inis ?)

Re: Can you add a cm command to restart TC?

Posted: 2022-09-08, 00:15 UTC
by petermad
(PS: is there anyway to make TC load usercmd.ini from a userdefined folder like %Commander_Path%\Inis ?
No - TC will load it from the same directory as the current wincmd.ini file (location can be seen via the Menu: "Help" -> "About Total Commander".

But if you start TC like this:

Code: Select all

drive:\path\totalcmd64.exe /i=drive:\path\inis\wincmd.ini /f=drive:\path\inis\wcx_ftp.ini
then all inis (wincmd.ini, wcx_ftp.ini, fsplugin.ini, lsplugin.ini, pkplugin.ini and contplug.ini plus some plugins-specific inis) will be used from drive:\path\inis\

Notice you cannot use %Commander_Path% until TC is started (unless you have added it to Windows' environment manually).

The location of plugin ini files can be controlled in the [ReplaceIniLocation] section of your wincmd.ini file
Help wrote:[ReplaceIniLocation] Set a different ini file location for specific plugins, via function *SetDefaultParams, parameter DefaultIniName, via line pluginfile.ext=c:\path\newinifile.ini or pluginfile.ext=c:\path\ - the plugin may ignore the name and just use the path.
pluginname.ext= New location of ini file sent to the plugin. The plugin name must be specified without path, and with extension as configured in wincmd.ini, e.g. sftpplug.wfx
Special values:
* send default value, but redirect to user profile if location not writable (default for packer, file system, and lister plugins)
- send default value, but do not redirect to user profile on fail (default for content plugins)
Example:

Code: Select all

[ReplaceIniLocation]
cloudplugin.wfx=%COMMANDER_PATH%\PLUGINS\wfx\cloudplugin\tccloud.ini
sftpplug.wfx=%COMMANDER_PATH%\PLUGINS\wfx\sftpplug\sftpplug.ini
CHMDir.wcx=%COMMANDER_PATH%\PLUGINS\wcx\CHMDir\CHMDir.ini

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 03:15 UTC
by Sir_SiLvA
petermad wrote: 2022-09-08, 00:15 UTC
(PS: is there anyway to make TC load usercmd.ini from a userdefined folder like %Commander_Path%\Inis ?
No - TC will load it from the same directory as the current wincmd.ini file (location can be seen via the Menu: "Help" -> "About Total Commander".

Example:

Code: Select all

[ReplaceIniLocation]
cloudplugin.wfx=%COMMANDER_PATH%\PLUGINS\wfx\cloudplugin\tccloud.ini
sftpplug.wfx=%COMMANDER_PATH%\PLUGINS\wfx\sftpplug\sftpplug.ini
CHMDir.wcx=%COMMANDER_PATH%\PLUGINS\wcx\CHMDir\CHMDir.ini
Thanks again I somehow missed [ReplaceIniLocation] when I read the history file :-(.
Also I only have decThumbsDBViewer.wlx (old and only 32Bit) and tcwebdav.wfx (by Chris)
as "bad boys" who save their inis in the wrong folder :)

PS:
1) I guess CHMDir.wcx was just an example because mine has its ini in its own folder
2) In my wincmd.ini under [Configuration] I have the key ‹L$÷A=6029370 you wouldnt by any change know what that is?

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 07:47 UTC
by petermad
2Sir_SiLvA
In my wincmd.ini under [Configuration] I have the key ‹L$÷A=6029370 you wouldnt by any change know what that is?
Sorry I have no idea - I doubt very much that it is TC that has put it there.

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 08:20 UTC
by monarch-lfv
2petermad
Thank You!
Great solution. And what about fast switching between TCх32 and TCх64?

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 08:56 UTC
by Horst.Epp
While in the x64 version I use this button to start an x32 instance.

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\TOTALCMD.EXE
%Z/N %X"%P" "%T"
%COMMANDER_PATH%\TOTALCMD.EXE
TC x86

0
-1

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 09:45 UTC
by petermad
Horst.Epp wrote: 2022-10-02, 08:56 UTC While in the x64 version I use this button to start an x32 instance.

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\TOTALCMD.EXE
%Z/N %X"%P" "%T"
%COMMANDER_PATH%\TOTALCMD.EXE
TC x86

0
-1
May I suggest to modify this to:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\TOTALCMD.EXE
%Z /N /P %X %P%N* %T%M*
%COMMANDER_PATH%\TOTALCMD.EXE
TC x86

0
-1
Then the cursor will be placed on the same files/folders as in the 64bit version

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 10:58 UTC
by Horst.Epp
Thanks petermad :D
Much better than my version.
You are still the best

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 11:19 UTC
by petermad
:oops:

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 11:45 UTC
by monarch-lfv
2Horst.Epp, 2petermad
Thanks! But I mean, one button, which change version TC "round trip". If executed Totalcmd.exe then start Totalcmd64.exe, and if executed Totalcmd64.exe then start Totalcmd.exe (one button!).
There is such an implementation in the mentioned TCIMG.

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 11:56 UTC
by Horst.Epp
monarch-lfv wrote: 2022-10-02, 11:45 UTC 2Horst.Epp, 2petermad
Thanks! But I mean, one button, which change version TC "round trip". If executed Totalcmd.exe then start Totalcmd64.exe, and if executed Totalcmd64.exe then start Totalcmd.exe (one button!).
There is such an implementation in the mentioned TCIMG.
Not a scenario which makes sense for me.
I always use the x64 version and only for some tests
or using an old 32bit plugin I start the x86 version.
After stopping this I'm still in the x64 TC.

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 12:07 UTC
by Fla$her
2monarch-lfv

Code: Select all

;:::::::::::::::::::::: AU3 :::::::::::::::::::::::
; Restarting TC switching the x32<>x64 architecture
; Parameter in the Command field: "%COMMANDER_EXE%"
; Release date: 05/03/2019
;::::::::::::::::::::::::::::::::::::::::::::::::::
#NoTrayIcon
Local $hWnd = WinActive("[CLASS:TTOTAL_CMD]")
If $hWnd Then
  Opt("WinWaitDelay", 40)
  Local $TC = $CmdLine[1], $PFix = '', $n = 4
  WinClose($hWnd)
  ProcessWaitClose(WinGetProcess($hWnd))
  If @OSArch <> 'x86' Then
    If StringRight($TC, 6) = '64.EXE' Then
      $n = 6
    Else
      $PFix = '64'
    EndIf
  EndIf
  $PID = Run(StringLeft($TC, StringLen($TC) - $n) & $PFix & '.EXE')
  WinWaitActive("[CLASS:TTOTAL_CMD]")
  $WSS = ObjCreate('WScript.Shell')
  $WSS.AppActivate($PID)
EndIf

Re: Can you add a cm command to restart TC?

Posted: 2022-10-02, 12:14 UTC
by petermad
monarch-lfv wrote: 2022-10-02, 11:45 UTC Thanks! But I mean, one button, which change version TC "round trip". If executed Totalcmd.exe then start Totalcmd64.exe, and if executed Totalcmd64.exe then start Totalcmd.exe (one button!).
There is such an implementation in the mentioned TCIMG.
To make a toggle-button do this:

Put this command in your usercmd.ini file (located in the same dir as your wincmd.ini file, if not present make it):

Code: Select all

[em_othercommander]
cmd=%COMSPEC% /C
param=%Z%X if "%%COMMANDER_EXE%%"=="%%COMMANDER_PATH%%\TOTALCMD.EXE" (start "" "%%COMMANDER_PATH%%\TOTALCMD64.EXE" /N /P /A /i="%%COMMANDER_INI%%" %P%N* %T%M*) else start "" "%%COMMANDER_PATH%%\TOTALCMD.EXE" /N /P /A /i="%%COMMANDER_INI%%" %P%N* %T%M*
menu=Open opposite bitness of Total Commander
button=%COMMANDER_EXE%
iconic=1
And make a button with this command:

Code: Select all

TOTALCMD#BAR#DATA
em_othercommander, cm_Exit

%COMMANDER_EXE%
Open opposite bitness of Total Commander
To make the button:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".

For this to work the 64bit and the 32bit version of TC of course has to be installed in the same directory.