Environment variable for directory of wincmd.ini
Moderators: Hacker, petermad, Stefan2, white
Environment variable for directory of wincmd.ini
Hi,
I'd like to suggest adding an environment variable for the directory in which wincmd.ini resides in.
Note: %COMMANDER_INI% gives the full path e.g. C:\tc\wincmd.ini but what I'd like to get is C:\tc
Reason: I'm using customized icons (in default.bar) and this would be a nice feature to easily transfer TC to another computer (and keeping those icon files).
Thanks!
I'd like to suggest adding an environment variable for the directory in which wincmd.ini resides in.
Note: %COMMANDER_INI% gives the full path e.g. C:\tc\wincmd.ini but what I'd like to get is C:\tc
Reason: I'm using customized icons (in default.bar) and this would be a nice feature to easily transfer TC to another computer (and keeping those icon files).
Thanks!
Hello, Henrie. Hello, burg1.
%COMMANDER_PATH% points to the Total Commander programme folder. The file wincmd.ini may be stored there, but it need not.
Therefore %COMMANDER_PATH% cannot be used as a reliable way of pointing to the folder where %COMMANDER_INI% is located.
Much in the same way, %COMMANDER_DRIVE% only points to the drive where %COMMANDER_PATH% is located. %COMMANDER_INI% may or may not be stored on the same drive.
So neither %COMMANDER_DRIVE%, nor %COMMANDER_PATH% give any reliable hint where %COMMANDER_INI% may be found.
Yet, there is a dirty little trick which can do so, provided you do so inside Total Commander itself or inside a process which has enherited the Total Commander environment:
This seems to fail e.g. if you try to use it on Wine. It seems to work fine on Windows, however.
Summary:
burg1, you are right. Currently there is no T.C. internal variable which points to the folder where %COMMANDER_INI% is located. The same is true for the location of wcx_ftp.ini. There is no T.C. internal variable which points to its folder. It would be nice to have such environment variables though.
Kind regards,
Karl
%COMMANDER_PATH% points to the Total Commander programme folder. The file wincmd.ini may be stored there, but it need not.
Therefore %COMMANDER_PATH% cannot be used as a reliable way of pointing to the folder where %COMMANDER_INI% is located.
Much in the same way, %COMMANDER_DRIVE% only points to the drive where %COMMANDER_PATH% is located. %COMMANDER_INI% may or may not be stored on the same drive.
So neither %COMMANDER_DRIVE%, nor %COMMANDER_PATH% give any reliable hint where %COMMANDER_INI% may be found.
Yet, there is a dirty little trick which can do so, provided you do so inside Total Commander itself or inside a process which has enherited the Total Commander environment:
Note:%COMMANDER_INI%\..
This seems to fail e.g. if you try to use it on Wine. It seems to work fine on Windows, however.
Summary:
burg1, you are right. Currently there is no T.C. internal variable which points to the folder where %COMMANDER_INI% is located. The same is true for the location of wcx_ftp.ini. There is no T.C. internal variable which points to its folder. It would be nice to have such environment variables though.
Kind regards,
Karl
Hello karlchen,
Burg1 gave an example
%COMMANDER_DRIVE% I just put in there because it is fairly new and is handy in case one likes to use a portable TC.
Regards,
Henrie
Burg1 gave an example
Therefore i thought the variable %COMMANDER_PATH% would suffice in his case.burg1 wrote:Note: %COMMANDER_INI% gives the full path e.g. C:\tc\wincmd.ini but what I'd like to get is C:\tc
%COMMANDER_DRIVE% I just put in there because it is fairly new and is handy in case one likes to use a portable TC.
Regards,
Henrie
Hello, Henrie.
You are absolutely right, in Burg1's example %COMMANDER_INI% is stored inside the T.C. programme folder. Therefore in this special case, %COMMANDER_PATH% holds the fully qualified foldername of the folder where %COMMANDER_INI% lives.
I had tried to explain that this were a special case and that %COMMANDER_INI% need not even be stored on the same drive as the Total Commander programme folder.
Kind regards,
Karl
You are absolutely right, in Burg1's example %COMMANDER_INI% is stored inside the T.C. programme folder. Therefore in this special case, %COMMANDER_PATH% holds the fully qualified foldername of the folder where %COMMANDER_INI% lives.
I had tried to explain that this were a special case and that %COMMANDER_INI% need not even be stored on the same drive as the Total Commander programme folder.
Kind regards,
Karl
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Please see, Setting Environment Variables | Passing Vars between Apps
You can set additional permanent Environment variables, such as you want - the command in question only needs to be run once per machine.
Eg, all of this used to be in the .cmd I use to launch TC, now I ran it once and added them as User Environment Variables:
For instance, I use the TCDATA var for a lot of the Icon fields in the buttonBar:
You can set additional permanent Environment variables, such as you want - the command in question only needs to be run once per machine.
Eg, all of this used to be in the .cmd I use to launch TC, now I ran it once and added them as User Environment Variables:
Code: Select all
@ECHO OFF
:: SET PATH=%SYS32%;C:\WIN2K;%wuBIN%;%wuBin%\exCMD;%wuBIN%\exDOS;%SYS32%\Wbem
SETENV -u AHKDir "%ProgramFiles%\AutoHotKey"
SETENV -u AHKICO "%AHKDir%\AutoHotkey_AHK1.icl"
SETENV -u AHK "\"%AHKDir%\AutoHotkey.exe\" \"%%AHKDir%%\Scripts\""
SETENV -u AppAccess "%ProgramFiles%\Accessories"
SETENV -u APPLOCAL "%USERPROFILE%\Local Settings\Application Data"
::
:: Applications
:: \Program Files\$CATegory
::
SET count=0
CD %ProgramFiles%
FOR /F "usebackq delims=?" %%F IN (`dir /a:d /o:n /b` ) DO CALL:_SET_PARENT_FOLDERS "%%F"
SETENV -u AppAccess "%ProgramFiles%\Accessories"
::
:: Applications
:: \Program Files\$Graphics\$__SubCat
::
SET count=0
CD "%AppGraphics%"
FOR /F "usebackq delims=?" %%F IN (`dir /a:d /o:n /b` ) DO CALL:_SET_GRAPHIC_FOLDERS "%%F"
SETENV -u TC "%ProgramFiles%\TotalCMD"
SETENV -u TCmd "%TC%\TotalCMD.exe"
SETENV -u TCDATA "%APPDATA%\_TC_"
SETENV -u TCTOOL "%wuBIN%\TCTools"
SETENV -u TCMC "%TCTOOL%\TCMC.exe 50"
:: junction -d "%TC%\Data"
:: junction "%TC%\Data" "%TCDATA%"
SET count=
SET tmpF=
GOTO:EOF
::
:: Workaround for CMD.exe limitation: Refuses to properly SET a variable that contains characters such as: ¤ or §
:: -- ( If the string is retrieved from a DIR command)
:: -- eg: %ProgramFiles%\¤Graphics
::
:: Yet I have found it _does_ SET the proper variable from %CD% ...
::
:_SET_PARENT_FOLDERS
SET /A count=%count% + 1
IF %count% GTR 7 GOTO:EOF
SET "tmpF=%~1"
SET "tmpF=%tmpF:~1%"
PUSHD "?%tmpF%"
SETENV -u App%tmpF% "%CD%"
POPD
GOTO:EOF
::
:: Likewise, above: CMD.exe will not SET a variable that contains: §
:: -- such as %ProgramFiles%\¤Graphics\§__Image_View
::
:_SET_GRAPHIC_FOLDERS
SET /A count=%count% + 1
IF %count% GTR 6 GOTO:EOF
SET "tmpF=%~1"
SET "tmpF=%tmpF:~1%"
PUSHD "?%tmpF%"
SET "tmpF=%tmpF:_=%"
SETENV -u "g%tmpF%" "%CD%"
POPD
::SET "g%tmpF%=%CD%\%~1"
GOTO:EOF
Where TCDATA == %APPDATA%\_TC_Icon file: %TCDATA%\GUI\icons\mwmTotalCmd2.icl
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
If you are using a command prompt you could do something like:
Dunno if that's WINE friendly or not. But this would (should?) work WINE/Linux, May need to change how the variable is referenced, maybe: $COMMANDER_INI ... ?
And this would work, with AutoHotkey,
EDIT:
And for completeness, here's a few path related functions I wrote for AHK:
Example usage of SplitPathCMD() ... uses the same/similiar syntax as CMD.exe variable referencing:
Will handle the CMD.exe letters, f d p s n x --- although f will exclude/trump the others.
E.G.
Code: Select all
::
:: TC_QueryINIPath.cmd
::
@ECHO OFF
FOR /F "delims=" %%F IN ("%COMMANDER_INI%") DO SET TCINI_PATH=%%~pF
Code: Select all
basename "%COMMANDER_INI%" wincmd.ini
And this would work, with AutoHotkey,
Code: Select all
EnvGet, TCINI, COMMANDER_INI
SplitPath, TCINI,, path
path.="\"
MsgBox, path: %path%
And for completeness, here's a few path related functions I wrote for AHK:
Code: Select all
SplitPathCMD(fullPath, byref str1, byRef str2="", byref str3="", byRef str4="")
{
Loop, %fullPath%, 1
fullPath:=A_LoopFileLongPath
if( inStr(FileExist(fullPath), "D") )
slash:=(SubStr(fullPath, 0) <> "\" ? "\" : "")
else
fullPath:=(SubStr(fullPath, 0) == "\" ? SubStr(fullPath, 1,-1) : fullPath)
Loop, 4
{
out:=""
if(!sTmp:=str%A_Index%)
break
if(inStr(sTmp, "s") || ((full:=fullPath) && FALSE))
Loop, %fullPath%, 1
full:=A_LoopFileShortPath
if((inStr(sTmp, "f") && str%A_Index%:=full) || ((full.=slash) && FALSE))
continue
SplitPath, full, aFile, aDir, aExt, aNameOnly, aDrive
out:=(inStr(sTmp, "dp") ? aDir : inStr(sTmp, "d") ? aDrive : inStr(sTmp, "p")
? (RegExReplace(aDir, "^.:", aDir==aDrive ? "\" : "")(aFile ? "\" : "")) : "")
out.=(inStr(sTmp, "nx") ? aFile : inStr(sTmp, "n") ? aNameOnly : (inStr(sTmp, "x") && aExt) ? "." aExt : "" )
str%A_Index%:=out
}
}
SplitPath( fullPath, byRef aFile="", byRef aDir="", byRef aExt="", byRef aDrive="", byRef aNameOnly="" )
{
fullPath.=((inStr(FileExist(fullPath), "D") && SubStr(fullPath, 0) <> "\") ? "\" : "")
SplitPath, fullPath, aFile, aDir, aExt, aNameOnly, aDrive
aDir.=(aDir && (aDir==aDrive)) ? "\" : ""
return
}
Code: Select all
EnvGet, TCINI, COMMANDER_INI
SplitPathCMD(TCINI, path:="dp")
MsgBox, path: %path%
E.G.
SplitPathCMD(TCINI, fullPath:="f", drive:="d", ext:="x", shortname:="snx")
MsgBox, fullpath: %fullpath%`ndrive: %drive%`next: %ext%`nshortname: %shortname%