Can't use %PROCESSOR_ARCHITECTURE:~3,2% in TC cmd-line

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
MaxX
Power Member
Power Member
Posts: 1029
Joined: 2012-03-23, 18:15 UTC
Location: UA

Can't use %PROCESSOR_ARCHITECTURE:~3,2% in TC cmd-line

Post by *MaxX »

I need but can't use "%PROCESSOR_ARCHITECTURE:~3,2%" in TC command line.
CMD.exe works with fine with it.

For example, try Imagine.wlx plugin with it's EXE versions (both 32 and 64 bit in same dir):
"%COMMANDER_PATH%\Plugins\wlx\Imagine\Imagine%PROCESSOR_ARCHITECTURE:~3,2%.exe"
Result:
1. "x86" string gives empty line and CMD.exe lanuches Imagine.exe.
2. "amd64" gives "64" and CMD.exe lanuches Imagine64.exe.

Any ideas?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You're talking about specific feature of cmd.exe which is not supported by TC or other software so it works as it should.

If you need some variables that depend on TC bitness, you can define them with Autorun plugin using its conditional operators.
User avatar
petermad
Power Member
Power Member
Posts: 14791
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2MaxX
Any ideas?
1) Rename your imagine.exe to imaginex86.exe and rename your imagine64.exe to imagineamd64.exe and use "%COMMANDER_PATH%\Plugins\wlx\Imagine\Imagine%PROCESSOR_ARCHITECTURE%.exe"

2) Or make an imagine.cmd file whis the line:
"%COMMANDER_PATH%\Plugins\wlx\Imagine\Imagine%PROCESSOR_ARCHITECTURE:~3,2%.exe"

3) Or make a button-bar button with this content

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
Start "Imagine" "%%COMMANDER_PATH%%\Plugins\wlx\Imagine\Imagine%%PROCESSOR_ARCHITECTURE:~3,2%%.exe"
"%COMMANDER_PATH%\PLUGINS\wlx\Imagine\Imagine.exe"
Imagine Viewer

1
-1
4) Or make an internal commsnd with this code:

Code: Select all

[em_imagine]
button="%COMMANDER_PATH%\PLUGINS\wlx\Imagine\Imagine.exe"
cmd=%COMSPEC% /C
param=Start "Imagine" "%%COMMANDER_PATH%%\Plugins\wlx\Imagine\Imagine%%PROCESSOR_ARCHITECTURE:~3,2%%.exe"
iconic=1
menu=Imagine Viewer
5) Make an alias in wincmd.ini: [Alias]img=em_imagine

You can then use imagine.cmd or em_imagine or img on the commandline.

Or you can put your own Imagine item in the main menu:
MENUITEM "Imagine Viewer", em_imagine

If you want to use the button or em_imagine command to open the file under the cursor in TC, then just add %P%N to the button or the em_imagine command - like:

Code: Select all

Start "Imagine" "%%COMMANDER_PATH%%\Plugins\wlx\Imagine\Imagine%%PROCESSOR_ARCHITECTURE:~3,2%%.exe" %P%N
If you want to use the em_imagine command or img alias to open a file added to the command line, then just add "%A" to the em_command - like:

Code: Select all

param=Start "Imagine" "%%COMMANDER_PATH%%\Plugins\wlx\Imagine\Imagine%%PROCESSOR_ARCHITECTURE:~3,2%%.exe" "%A"
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Andreas85
Junior Member
Junior Member
Posts: 34
Joined: 2015-08-21, 09:35 UTC
Location: Harz

Post by *Andreas85 »

I'm so excited...
User avatar
karlchen
Power Member
Power Member
Posts: 4601
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

<side note>
Like another recent "bug" thread, this thread, too, does not qualify as a Total Command bug thread.
The reported behaviour is not caused by any misbehaviour of T.C. at all.
When you launch T.C. it is not T.C. itself that parses the commandline but Windows.
This thread should be moved to the normal English sub-forum, please.
</side note>

<confession>
Argh. :oops: I confess not having read carefully enough the initial post.
It is about the situation where a new TC instance is launched from inside a running TC instance.

Nonetheless, we are not talking about a Total Commander 9.0beta bug here:

If you want to use environment variables in places where you can also use Total Commander internal parameter variables like %P, %T, %N, etc, you have to surround the environment variables with double ampersand %%, like petermad had already explained above.
</confession>

<Result>
The result remains the same: not a T.C. bug.
Only the first reason that I had given did not match the situation. (How embarrassing. :oops: )
</Result>
Last edited by karlchen on 2016-08-07, 21:02 UTC, edited 4 times in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Can't use %PROCESSOR_ARCHITECTURE:~3,2% in TC cmd-line

Post by *Horst.Epp »

MaxX wrote:I need but can't use "%PROCESSOR_ARCHITECTURE:~3,2%" in TC command line.
CMD.exe works with fine with it.

For example, try Imagine.wlx plugin with it's EXE versions (both 32 and 64 bit in same dir):
"%COMMANDER_PATH%\Plugins\wlx\Imagine\Imagine%PROCESSOR_ARCHITECTURE:~3,2%.exe"
Result:
1. "x86" string gives empty line and CMD.exe lanuches Imagine.exe.
2. "amd64" gives "64" and CMD.exe lanuches Imagine64.exe.

Any ideas?
Please don't make bug reports for problems or questions which are obviously no TC bug at all. There are enough other TC forums you can use.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
MaxX
Power Member
Power Member
Posts: 1029
Joined: 2012-03-23, 18:15 UTC
Location: UA

Post by *MaxX »

Yes. Not a bug. Just an imperfection.
But IMHO it would be better to use ":~3,2" directly in TC.
Cmd.exe can be blocked by security policy.
It is a good time to implement this feature in new beta.
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Moved to the English forum.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
MaxX
Power Member
Power Member
Posts: 1029
Joined: 2012-03-23, 18:15 UTC
Location: UA

Post by *MaxX »

Christian, do you plan to add ":~3,2" support?
That would be great for universal x32/x64 portable installation to use it on diffrent PCs.
Ukrainian Total Commander Translator. Feedback and discuss.
Skif_off
Member
Member
Posts: 132
Joined: 2013-09-30, 13:13 UTC

Post by *Skif_off »

MaxX wrote:for universal x32/x64 portable installation to use it on diffrent PCs.
With Autorun plugin:

Code: Select all

"%COMMANDER_PATH%\Plugins\wlx\Imagine\Imagine%OSARCH%.exe"
Autorun.cfg:

Code: Select all

LoadLibrary Plugins\Autorun_Sysinfo.dll
...

If %SYSINFO_OSARCH% = 64 Then
  SetEnv OSARCH 64
Else
  SetEnv OSARCH
EndIf
P.S. Other examples:

Code: Select all

# For SumatraPDF + Ghostscript:
SetEnv /A PATH ;%COMMANDER_PATH%\Plugins\wlx\sLister\GS

# uLister without folder %UserProgfile%\.oit:
SetEnv OIT_DATA_PATH %COMMANDER_PATH%\Plugins\wlx\uLister
# or
SetEnv OIT_DATA_PATH %COMMANDER_PATH%\Temp
# or
SetEnv OIT_DATA_PATH %Temp%
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Skif_off,
Does defining empty envvar work for you? In my tests Windows simply doesn't expand empty envvars and leaves varname with percent chars as is, so I just defined vars with full paths or with dot to make that working (hopefully I never had any real need in executing 64-bit app versions).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48075
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Christian, do you plan to add ":~3,2" support?
It's the first time I have heared about this feature of cmd.exe! I will add it to my wish list, but it's a very bad moment to add that now to TC9: It's already at release candidate 4, and each new feature will further delay the release...
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I doubt that TC should support all cmd-specific internal things like pseudo-envvars or substrings/replacements using %:~% (such stuff is described in set /? output)...
User avatar
Dalai
Power Member
Power Member
Posts: 9386
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

I second MVV's opinion. There are enough other ways, like launching some batch script which can then use the syntax specific to CMD.

Regards
Dalai
#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
MaxX
Power Member
Power Member
Posts: 1029
Joined: 2012-03-23, 18:15 UTC
Location: UA

Post by *MaxX »

ghisler(Author) wrote:
Christian, do you plan to add ":~3,2" support?
It's the first time I have heared about this feature of cmd.exe! I will add it to my wish list, but it's a very bad moment to add that now to TC9: It's already at release candidate 4, and each new feature will further delay the release...
That would be great for ver.10 or 9.5. Thanks.
Post Reply