Allow expanding empty envvars in command line/BAR/USERCMD

Here you can propose new features, make suggestions etc.

Moderators: Stefan2, white, sheep, Hacker

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

Allow expanding empty envvars in command line/BAR/USERCMD

Post by *MVV » 2018-05-22, 05:33 UTC

Currently TC doesn't expand envvar if its value is empty string, it just leaves %var% in a string, and this causes execution errors. I've checked, ExpandEnvironmentStrings system function does expand such vars properly, e.g. it expands %COMMANDER_PATH%\Tools\Program\Program%EMPTY_OR_64%.exe to D:\TOTALCMD\Tools\Program\Program.exe when EMPTY_OR_64 variable is set to empty string.

I know that empty variables can only be set with some third-party tools or plugins that call SetEnvironmentVariable function but sometimes it is really handy to have them when you want to e.g. start 64-bit programs under 64-bit Windows and 32-bit under 32-bit one.

E.g. one can use Autorun content plugin for auto-setting such variables depending on Windows bitness:

Code: Select all

LoadLibrary Plugins\Autorun_Sysinfo.dll

If %SYSINFO_OSARCH% = 32 Then
	SetEnv OS_EMPTY_OR_64
	SetEnv OS_EMPTY_OR_64_SLASH
Else
	SetEnv OS_EMPTY_OR_64 64
	SetEnv OS_EMPTY_OR_SLASH_64 \64
EndIf

If %AUTORUN_TCARCH% = 32 Then
	SetEnv TC_EMPTY_OR_64
	SetEnv TC_EMPTY_OR_64_SLASH
Else
	SetEnv TC_EMPTY_OR_64 64
	SetEnv TC_EMPTY_OR_SLASH_64 \64
EndIf
And then such variables may be used in BAR/USERCMD e.g. for launching binaries with names ending with 64 or ones that are placed to 64\ subdir of TC dir:

Code: Select all

Command=%COMMANDER_PATH%\Tools\Program\Program%OS_EMPTY_OR_64%.exe

Code: Select all

Command=%COMMANDER_PATH%%TC_EMPTY_OR_SLASH_64%\Program.exe
Or from command line:

Code: Select all

Program%OS_EMPTY_OR_64%.exe
Please make it working. It won't break anything because it is not so trivial to set such variables.

User avatar
LonerD
Senior Member
Senior Member
Posts: 298
Joined: 2010-06-19, 20:18 UTC
Location: Donetsk

Re: Allow expanding empty envvars in command line/BAR/USERCMD

Post by *LonerD » 2018-07-23, 22:00 UTC

MVV wrote:
2018-05-22, 05:33 UTC
E.g. one can use Autorun content plugin for auto-setting such variables depending on Windows bitness:
I use ^. Many commands related to empty variable.
It's works in TC 9.12 and early versions, but now in TC 9.20 my commands are totally broken. :(
Please, return previous functionality.
Total Commander DreamLair - dream always, think totally, be the commander of you own life.

Post Reply