[WDX] Autorun Plugin: Run commands/set envvars on TC start

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, sheep, Hacker, Stefan2

User avatar
MVV
Power Member
Power Member
Posts: 8121
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

[WDX] Autorun Plugin: Run commands/set envvars on TC start

Post by *MVV » 2011-11-07, 12:16 UTC

This is a pseudo-content plugin that intended to perform some tasks at Total Commander start. You can run a file, execute TC command (both cm_ and em_), set environment variable, set delay between commands, write value to ini file, load library or plugin. Commands are read from text configuration file.

This plugin is a simple command processor that executes commands from text configuration file.
All commands are executed in the separate thread and should not freeze TC in case of problem in one of commands. It is possible to use variables and simple If..Else condition block.

Plugin allows to perform following tasks on TC start:
* run external tools with parameters
* set environment variables within TC address space (they may be used e.g. from TC buttonbar then)
* run internal cm_ or em_ commands or change path in TC panels
* open specific directories on TC start
* load specific font that may be used by TC
* load DLLs (e.g. plugin modules or other addons like TCFS2Tools)
* perform different actions depending on some INI values, envvars or TC bitness


Plugin archive includes module MoveButton that moves 'Options >>' button in copy/move dialogs to old good position (like in TC 7).


Important! Plugin requires special manual installation procedure.

See Readme file and sample script autorun.example.cfg for details.


Download last release



Since version 1.6 beta 13 64-bit version is also available, variable AUTORUN_TCARCH allows to execute specific commands for x32 or x64 version only via condition block in Autorun.cfg:

Code: Select all

If %AUTORUN_TCARCH% = 32 Then
	SetEnv /EV COMMANDER_PROGRAM %COMMANDER_PATH%\TOTALCMD.EXE
Else
	SetEnv /EV COMMANDER_PROGRAM %COMMANDER_PATH%\TOTALCMD64.EXE
EndIf
Last edited by MVV on 2014-03-14, 06:02 UTC, edited 8 times in total.

User avatar
tbeu
Power Member
Power Member
Posts: 1197
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu » 2011-11-07, 13:53 UTC

MVV wrote:Autorun.wdx[64] 1.6 beta 2 released
Would be nice if plugin supports configuration file in directory of wincmd.ini (not just in plugin directory which may be write-protected).
MVV wrote:AUTORUN_TCARCH to get TC bitness
Could you please add this to the example.cfg (possibly commented out).

Code: Select all

wincmd\
-> Plugins\
-> Tools\
wincmd64\
I have two different directories for 32 and 64 bit TC and can finally use new environment variable %COMMANDER32_DIR% to access the Tools and Plugins subdirectories of 32 bit TC installation from 32 bit and 64 bit TC without the need of full/absolute file pathes. Thank you!
readme_en.txt wrote:• In the "Define selection" dialog move to "Plugins" tab.
As TC 7.56a remembers the search settings the search string in the "General" tab needs to be cleared first. I had very special search string and wondered (as first time user of autorun.wdx) why there was no %COMMANDER_PROGRAM% environment variable.
TC plugins: Autodesk 3ds Max Preview, Autodesk Revit Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

User avatar
MVV
Power Member
Power Member
Posts: 8121
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2011-11-07, 14:49 UTC

tbeu wrote:
MVV wrote:Autorun.wdx[64] 1.6 beta 2 released
Would be nice if plugin supports configuration file in directory of wincmd.ini (not just in plugin directory which may be write-protected).
This is a script file defined by administrator (not by plugin itself) so I don't see any reason to make it writeable by users. If you wish, you may edit file's permissions to allow writing (as I did).
tbeu wrote:
MVV wrote:AUTORUN_TCARCH to get TC bitness
Could you please add this to the example.cfg (possibly commented out).
Sounds good, I'll ask plugin author.

User avatar
tbeu
Power Member
Power Member
Posts: 1197
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu » 2011-11-07, 20:21 UTC

This is my German translation

Code: Select all

[DEU]
1=Fehler in Plugin "Autorun"
2=Fehler in Zeile [%d]:
3=Fehler bei Integerkonvertierung:
4=Ungültiger Parameter: %s
5=Fehlendes schließendes Anführungszeichen in Zeichenkette: %s
6=Unerwartetes Anführungszeichen %s in Zeichenkette: %s
7=Fehler im Befehlswert: %s
8=Befehlausführungsfehler.
9=Befehl nicht gefunden: %s
10=Variablenname und -text müssen gesetzt sein.
11=Dateiname, Sektion oder Schlüssel ist leer!
12=Fehler beim Schreiben der INI-Datei.
13=Dateiname oder Sektion ist leer!
14=Fehler beim Löschen aus INI-Datei.
15=Bibliothek %s kann nicht geladen werden.
16=Exportierte Funktion %s in Bibliothek nicht gefunden.
17=Konstante %s kann nicht neu definiert werden.
18=Operator %s ist hier nicht anwendbar.
19=Fehlendes "Then" in "If"-Bedingung.
20=Fehlendes "If" für Schlüsselwort "%s".
21=Unbekannter Befehl: %s
22=Datei nicht gefunden: %s
where string 7 (command value) is not evident for me. Does it me return value?

There are some typos in the English translation

Code: Select all

retreiving -> retrieving
Library have not such function -> has
"%s" keyword have not opening "If" -> has
I added the plugin to the official list of 64-bit plugins.
TC plugins: Autodesk 3ds Max Preview, Autodesk Revit Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

User avatar
MVV
Power Member
Power Member
Posts: 8121
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2011-11-09, 07:17 UTC

Language file is not needed during normal plugin usage as stated in Readme.

I'll report theese errors to author, thanks.

User avatar
Hacker
Moderator
Moderator
Posts: 11025
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker » 2011-11-09, 08:17 UTC

Message from moderator

Thread split from New environment variable needed.

Hacker (Moderator)
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

User avatar
tbeu
Power Member
Power Member
Posts: 1197
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu » 2011-11-09, 10:29 UTC

I need to correct my previous comment. If I use Autorun.wdx to automatically set the new environment variable %COMMANDER32_DIR%, this environment variable can be used in buttons of toolbar. However this new environment variable cannot be used for content plugins of custom columns. I.e. this wincmd.ini

Code: Select all

[ContentPlugins]
0=C:\MyProgramFiles\wincmd\Plugins\Autorun\autorun.wdx
1=%COMMANDER32_DIR%\Plugins\SVNDetails\SVNDetails.wdx
is not working with custom columns based on content plugin SVNDetails.wdx. It looks like TC cashes section [ContentPlugins] before Autorun.wdx gets loaded. That's a pitty as I need to switch back to absolute path names again.
TC plugins: Autodesk 3ds Max Preview, Autodesk Revit Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

User avatar
MVV
Power Member
Power Member
Posts: 8121
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2011-11-09, 10:53 UTC

I think TC reads list of plugins before loading them (at that time envvar is not defined yet).

Why not to use COMMANDER_PATH variable here?

User avatar
tbeu
Power Member
Power Member
Posts: 1197
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu » 2011-11-09, 11:15 UTC

MVV wrote:I think TC reads list of plugins before loading them (at that time envvar is not defined yet).
Yes, TC reads list and also expands environment variables. Better to expand environment variable later just before plugin gets loaded.
MVV wrote:Why not to use COMMANDER_PATH variable here?
Because path name %COMMANDER_PATH%\Plugins\ exists only for TC 32bit and not for TC 64bit using the same wincmd.ini. Not portable at all.
TC plugins: Autodesk 3ds Max Preview, Autodesk Revit Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

User avatar
Horst.Epp
Power Member
Power Member
Posts: 3059
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp » 2011-11-09, 12:50 UTC

tbeu wrote:
MVV wrote:I think TC reads list of plugins before loading them (at that time envvar is not defined yet).
Yes, TC reads list and also expands environment variables. Better to expand environment variable later just before plugin gets loaded.
MVV wrote:Why not to use COMMANDER_PATH variable here?
Because path name %COMMANDER_PATH%\Plugins\ exists only for TC 32bit and not for TC 64bit using the same wincmd.ini. Not portable at all.
The commander_path variable exists also for x64 TC !
No problem here with portability

User avatar
MVV
Power Member
Power Member
Posts: 8121
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2011-11-09, 12:55 UTC

Horst.Epp, he uses separate folder for TCx64 so COMMANDER_PATH envvar can't help to get TCx32 installation directory (which contains plugins for both x32/x64)...

I don't see any problem in installing both versions into same folder though.

User avatar
tbeu
Power Member
Power Member
Posts: 1197
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu » 2011-11-09, 13:33 UTC

MVV wrote:he uses separate folder for TCx64 so COMMANDER_PATH envvar can't help to get TCx32 installation directory (which contains plugins for both x32/x64)
Correct. Apparently no one else has this kind of installation and complains about missing portability.
TC plugins: Autodesk 3ds Max Preview, Autodesk Revit Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

User avatar
tbeu
Power Member
Power Member
Posts: 1197
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu » 2011-11-14, 08:11 UTC

This is my solution: I moved Plugins and Tools directories one level up

Code: Select all

Plugins\
Tools\
wincmd\
wincmd64\
and changed wincmd.ini, too.

Code: Select all

[ContentPlugins]
0=%COMMANDER_PATH%\..\Plugins\Autorun\autorun.wdx
1=%COMMANDER_PATH%\..\Plugins\SVNDetails\SVNDetails.wdx
This way TC installation is portable and wincmd.ini can be used with TC 32bit and TC 64bit of different installation directories.
Last edited by tbeu on 2011-11-14, 11:26 UTC, edited 1 time in total.
TC plugins: Autodesk 3ds Max Preview, Autodesk Revit Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

User avatar
MVV
Power Member
Power Member
Posts: 8121
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2011-11-14, 10:19 UTC

Autorun 1.6 Beta 3 is available.
+ example of using conditional block is added to autorun.example.cfg
- language file mistakes
- fixed broken CommandExec command
- fixed crash on exit when using T/TT keys in ShellExec

tcvol
Junior Member
Junior Member
Posts: 66
Joined: 2009-02-02, 12:35 UTC

Post by *tcvol » 2011-11-14, 10:28 UTC

hi there

can you please post a few more examples to get more ideas of the .cfg file?
i have quite a lot of .cmd before/while tc starts, which are probably still needed, since tc has to be mounted and started from within a truecrypt volume and i need the information before tc is started.

but i think i could migrate the following things:
path to be synced (dropbox)
path not to be synced (tcmd addons)
start 3rd party apps if not already running

cheers

Post Reply