Only one loader for both 32 and 64-bit TC? Dedect OS-bitness

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
islogged
Senior Member
Senior Member
Posts: 205
Joined: 2008-09-17, 00:57 UTC

Only one loader for both 32 and 64-bit TC? Dedect OS-bitness

Post by *islogged »

Hi,

If you use Windows x32, u need to manually launch the Totalcmd.exe file.
If you use Windows x64, u need to manually launch the TOTALCMD64.EXE file.

Is there a way to have only one launcher who can automatically detect the version of windows (x32 or x64) and launch the appropriate version of TC ?

It's for a batch file !

Thank You ...
User avatar
Dalai
Power Member
Power Member
Posts: 10035
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Sure. This should do

Code: Select all

@echo off
REM Assume 32 bit
set "tcdir=%ProgramFiles%\Total Commander"
set tc=totalcmd.exe

REM If this env var is not empty, we are on a 64 bit system
if NOT "%ProgramFiles(x86)%"=="" (
    set tc=totalcmd64.exe
)

if exist "%tcdir%\%tc%" start "" "%tcdir%\%tc%"
Adapt the paths to your needs.

Note that it's not always useful to launch TC x64 on Windows x64. Sometimes you need TC x86 on Windows x64.

[EDIT]
I've changed the code above to fix some errors. Note that this script does not launch TC if it is run on a 32 bit CMD on Windows x64 (because of the mixup of path and exe)!
[/EDIT]

Regards
Dalai
Last edited by Dalai on 2016-02-02, 11:52 UTC, edited 1 time in total.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
silencer
Senior Member
Senior Member
Posts: 208
Joined: 2003-05-13, 13:18 UTC
Location: The Netherlands

Post by *silencer »

I have been using the following in the past... but most of the time i just launch the x64 directly.

Code: Select all

if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT
echo 32-bit OS
START "" ..\Programs\totalcmd\totalcmd.exe
goto END
:64BIT
echo 64-bit OS
START "" ..\Programs\totalcmd\TOTALCMD64.EXE
:END
The relative path needs to be changed to your needs.
islogged
Senior Member
Senior Member
Posts: 205
Joined: 2008-09-17, 00:57 UTC

Post by *islogged »

Hum, ok thank you.
It's mean TC don't do that and you need to detect this with a batch file ...

For this time i don't ve time to check this and your code.
But if i get problem with, i will back here.

Thank you so much again ...
User avatar
HerbieH
Member
Member
Posts: 154
Joined: 2003-02-11, 10:04 UTC

Post by *HerbieH »

To islogged:
You got a batch file as you asked for. :) :)

Anyhow I can confirm, that silencer's "AMD64" example works perfectly, now that you are 'too busy' to test the stuff, other people took their time to make for you.

BTW: Previous, I use "%PROCESSOR_ARCHITECTURE%"=="AMD64" a lot for detecting x32 /x64 versions of portable programs. Now all of my (and most of my friend's) Windows versions are x64, so detection is no so important anymore..

To silencer: Kill the 'mobius' ant already...
:)
HerbieH*
-Keep on makin' music!
islogged
Senior Member
Senior Member
Posts: 205
Joined: 2008-09-17, 00:57 UTC

Post by *islogged »

You got a batch file as you asked for. Smile Smile
Hum, no i never ask for a batch file solution, it's a misunderstanding ...

I told "It's for a batch file" ...
It's mean in one of my batch file i call the line : start TOTALCMD.EXE /i= etc... but it can't work if i execute on a x64 system ...
And if i put the line : start TOTALCMD64.EXE /i= etc... of course i've exactly the same problem if i execute it on a x32 system ...

I imagined we can detect the x32/x64 system first in the batch and launch the appropriate version of TC after ... (like Silencer or Dalai told)
But before i wanted to check here to know if TC come with some options to detect the host version system (x32/x64) in his code ... <--- just the subject of my question ^^

But it seam the answer is :
No, TC can't detect this by himself, you need to do it with/in your batch file ...

I already thank for that ^^
now that you are 'too busy' to test the stuff, other people took their time to make for you.
No worry, just the time to be busy with my batch file again ^^

Thanks for All
User avatar
HolgerK
Power Member
Power Member
Posts: 5412
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

islogged wrote:It's mean in one of my batch file i call the line : start TOTALCMD.EXE /i= etc... but it can't work if i execute on a x64 system ...
In case you are calling the batch file from an already running TC instance (button or command line) you can always use the environment variable %COMMANDER_EXE% to start a TC with the same bitness as the running TC.

Regards
Holger
User avatar
petermad
Power Member
Power Member
Posts: 16137
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2islogged
start TOTALCMD.EXE /i= etc... but it can't work if i execute on a x64 system ...
That is not true - you CAN run totalcmd.exe on a x64 sytem (provided that you have installed 32bit TC on that system), but you are right that you cannot run TOTALCMD64.EXE on a x86 (32bit) system.

From your previous posts, it seems that you believe that you can only run TOTALCMD64.EXE on x64 Windows, but you can just as well run TOTALCMD.EXE
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
islogged
Senior Member
Senior Member
Posts: 205
Joined: 2008-09-17, 00:57 UTC

Post by *islogged »

That is not true - you CAN run totalcmd.exe on a x64 sytem (provided that you have installed 32bit TC on that system)
From your previous posts, it seems that you believe that you can only run TOTALCMD64.EXE on x64 Windows, but you can just as well run TOTALCMD.EXE
Yeah, i don't know why i wrote that ???
It's a mistake ^^ (sorry)

Anyway, we can imagine to prefer launch a x64 version on a x64 system, to solve some problems of path (dixit: C:\Windows\SysWow64, C:\Windows\system32) and others ...

Just if I may counsel the author about this subject, we can imagine about 3 .exe files (just for a clean logic of the thing)

- Totalcmd32.exe file for x32 (or x64) system
- Totalcmd64.exe file for x64 system
- And a Totalcmd.exe file who can detect the host system version and launch the appropriate version of TC, for the most novices users of TC ...

It's just an idea ^^

Thanks for all of you and this community ...
User avatar
MaxX
Power Member
Power Member
Posts: 1193
Joined: 2012-03-23, 18:15 UTC
Location: UA

Post by *MaxX »

2islogged
Just make the link file for TC and replace the first line (how it looks like) with the following text:

Code: Select all

%ComSpec% /c if not exist "%ProgramW6432%" (start "" "C:\PROGRA~1\TC\TOTALCMD.EXE") else (start "" "C:\PROGRA~1\TC\TOTALCMD64.EXE")
where "C:\PROGRA~1\TC" is your path to TC (you need to change it for yours if you have diffrent place for TC)
Post Reply