Page 1 of 1

Allow expanding empty envvars in command line/BAR/USERCMD

Posted: 2018-05-22, 05:33 UTC
by MVV
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.

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

Posted: 2018-07-23, 22:00 UTC
by LonerD
MVV wrote: 2018-05-22, 05:33 UTCE.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.