Environment variables - path to USB drive

English support forum

Moderators: white, Hacker, petermad, Stefan2

Tsunulukai
Junior Member
Junior Member
Posts: 66
Joined: 2003-02-07, 23:44 UTC

Post by *Tsunulukai »

I tried it...

When you launch a program from the command prompt, the variables are remplaced before the program starts.... So %COMMANDER_PATH% is empty...

When you launch a program from the execute box in the start menu, the name of the variable is transfered to the program. In this case it's allright !

When you launch it from an autorun with the above settings, it seems that somehow TotalCommander don't get the correct parameters... I can't understand why

Code: Select all

[Autorun]
label=USB Key
icon=Tools\TotalCmd\Totalcmd.exe

action=Total Commander
action="@Tools\TotalCmd\Totalcmd.exe  /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L"
open="Tools\TotalCmd\Totalcmd.exe  /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L"

Shell=TotalCmd
Shell\TotalCmd=&Total Commander
Shell\TotalCmd\Command="Tools\TotalCmd\Totalcmd.exe  /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L"
When try this autorun :

Code: Select all

[Autorun]
shell\test=Test
shell\test\command=test.bat /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L
With test.bat as follows :

Code: Select all

REM Test.bat
ECHO %1 %2 %3 %4 %5
PAUSE
The command prompt shows :

Code: Select all

Z:\>REM TEST.BAT

Z:\>ECHO /L COMMANDER_PATH\ /R 1YSTEMDRIVE /P L
/L COMMANDER_PATH\ /R 1YSTEMDRIVE /P L

Z:\>PAUSE
I tried diffrent ways with and without quotes, but the result is the same :

Code: Select all

Z:\>REM TEST.BAT

Z:\>ECHO "/L=COMMANDER_PATH\ /R=1YSTEMDRIVE /P=L"
"/L=COMMANDER_PATH\ /R=1YSTEMDRIVE /P=L"

Z:\>PAUSE
Maybe there's now way to correctly pass this kind of variable using Autorun...

I also tried to put this in Wincmd.ini...

Code: Select all

[left]
path=%COMMANDER_PATH%

[right]
path=%SYSTEM_DRIVE%
but when launching total cmd, both pannels are on C:\

Any idea how I could solve the problem else than having to launch Tcmd trough a batch file that would popup for 1-2 seconds ?

Maybe Christian could consider the use of varibles to set the pannel path in wincmd.ini ?
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3299
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

Tsunulukai wrote: When you launch a program from the command prompt, the variables are remplaced before the program starts.... So %COMMANDER_PATH% is empty...
Sorry this is (excuse my language) %&%&% wrong.
FACT: If you do a "Example.exe %SystemUnknownVar%" the PRG example.exe
gets the %SystemUnknownVar% as Name and has to Replace it for itselft as the System doesnt knows it and leaves it as it is.
(At least on WinNT-Systems)
Tsunulukai wrote: When try this autorun :

Code: Select all

[Autorun]
shell\test=Test
shell\test\command=test.bat /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L
With test.bat as follows :

Code: Select all

REM Test.bat
ECHO %1 %2 %3 %4 %5
PAUSE
The command prompt shows :

Code: Select all

Z:\>REM TEST.BAT

Z:\>ECHO /L COMMANDER_PATH\ /R 1YSTEMDRIVE /P L
/L COMMANDER_PATH\ /R 1YSTEMDRIVE /P L

Z:\>PAUSE
I tried diffrent ways with and without quotes, but the result is the same :

Code: Select all

Z:\>REM TEST.BAT

Z:\>ECHO "/L=COMMANDER_PATH\ /R=1YSTEMDRIVE /P=L"
"/L=COMMANDER_PATH\ /R=1YSTEMDRIVE /P=L"

Z:\>PAUSE
If you read the Forum YOU WOULD KNOW THAT THIS CANT Work
as %Commander_Path% is NO SystemVar!!!

%Commander_Path% only works within TC!
OR as Commandline-Parameter when starting TC
like Totalcmd.exe /i=%Commander_path%\myini.ini

totalcmd.exe /R=%Commander_Path% /L=%systemdrive%
works here without a Problem here
WinXp SP2 German & TCv6.54a

Hope that helps a bit :D
Hoecker sie sind raus!
Tsunulukai
Junior Member
Junior Member
Posts: 66
Joined: 2003-02-07, 23:44 UTC

Post by *Tsunulukai »

I know that my sample batch file CAN'T work as %commander_drive% is not set... this batch was only intented to show what I get as parameters from an autorun start...

I just tried it to know how autorun handles transmission of the vars...
What I sait is that when I type "Z:\Tools\TotalCmd\Totalcmd.exe /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L" from the console, it does NOT work...

When I type it in the execute box, ok, fine, it works.

But when I try to launch it from autorun with those parameters... it fails !

So I tried to run a batch file from the autorun with the same parameters than the one I give to totalcmd.exe, just to see if the parameters are transmitted by autorun to the program...

What you see in the result box is what my batch file shows when launched by the autorun...

When I launch it manually, from the console, here's what it shows :

console openned from TC

Code: Select all

Z:\>test.bat /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L

Z:\>REM Test.bat

Z:\>ECHO /L C:\Util\TotalCmd\ /R D: /P
/L C:\Util\TotalCmd\ /R D: /P

Z:\>PAUSE
standard console :

Code: Select all

Z:\>test.bat /L=%COMMANDER_PATH%\ /R=%SYSTEMDRIVE% /P=L

Z:\>REM Test.bat

Z:\>ECHO /L %COMMANDER_PATH%\ /R D: /P
/L %COMMANDER_PATH%\ /R D: /P

Z:\>PAUSE
Those are NORMAL outputs....

but when launched by the autorun, here's what it returns...

Code: Select all

Z:\>REM TEST.BAT

Z:\>ECHO "/L=COMMANDER_PATH\ /R=1YSTEMDRIVE /P=L"
"/L=COMMANDER_PATH\ /R=1YSTEMDRIVE /P=L"

Z:\>PAUSE
That's weird, isn't it ?
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3299
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

What Do you get wenn you use %%Commander_Path% and %%Systemdrive%% in the Autorun.inf?

Besides the \ behind %Commander_Path% is NOT needed
Hoecker sie sind raus!
Tsunulukai
Junior Member
Junior Member
Posts: 66
Joined: 2003-02-07, 23:44 UTC

Post by *Tsunulukai »

That's it !
It works perfectly :D Thanks a lot !

For those who are interested, here's the code to autorun TotalCmd with one pannel showing the root of the usb key, and the other the system drive : Autorun.inf

Code: Select all

[Autorun]
label=USB Key
icon=Tools\TotalCmd\Totalcmd.exe

action=Total Commander
open=Tools\TotalCmd\Totalcmd.exe /L=%%COMMANDER_PATH%%\..\.. /R=%%SYSTEMDRIVE%% /P=L 

Shell=TotalCmd
Shell\TotalCmd=&Total Commander
Shell\TotalCmd\Command=Tools\TotalCmd\Totalcmd.exe /L=%%COMMANDER_PATH%%\..\.. /R=%%SYSTEMDRIVE%% /P=L 
Don't forget to put the autorun.inf in the root of your USB disk.

Thanks to Sir_SiLvA for helping me solving "the bug" :D
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3299
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

You're wolcome :D
Hoecker sie sind raus!
Post Reply