Command line alias?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Profane0360
Junior Member
Junior Member
Posts: 37
Joined: 2023-08-31, 20:08 UTC

Command line alias?

Post by *Profane0360 »

For some time I have been thinking about an alias to be able to use in command line (and in batch files called from TC command line), alias to a full path exe. The purpose is to avoid populating the path and, instead of using something along the lines of

c:\path\to\exe\someexe.exe somepar1 somepar2

to actually use

someexe somepar1 somepar2

with someexe as the defined alias. As far as I understood the documentation, I cannot create an alias to work in this way. Or I couldn't find how to. Could you give me a hint?
#155067 Personal licence (March 2007)
User avatar
Gral
Power Member
Power Member
Posts: 1600
Joined: 2005-01-26, 15:12 UTC

Re: Command line alias?

Post by *Gral »

There is many posibilities: most obvious - add program path to environment variables, note: you don't have to include ".exe" in the command so
"c:\path\to\exe\someexe.exe somepar1 somepar2" will become "someexe somepar1 somepar2" without any additional steps.
Profane0360
Junior Member
Junior Member
Posts: 37
Joined: 2023-08-31, 20:08 UTC

Re: Command line alias?

Post by *Profane0360 »

Thank you. My point is to avoid to modify the PATH environment variable.
#155067 Personal licence (March 2007)
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Command line alias?

Post by *tuska »

Maybe one or more em_commands and then assign an alias to the em_command?
User avatar
Gral
Power Member
Power Member
Posts: 1600
Joined: 2005-01-26, 15:12 UTC

Re: Command line alias?

Post by *Gral »

You can also use:
- Hard link
- Symbolic link
- Windows link (lnk file)
- BATCH file
- AHK script (or any other script)
- External launcher
Profane0360
Junior Member
Junior Member
Posts: 37
Joined: 2023-08-31, 20:08 UTC

Re: Command line alias?

Post by *Profane0360 »

Thank you. I am thinking at portable solutions. I prefer not to do it via links. Batch scripting is a solution indeed (but windows scripting is a joke compared to linux shell scripting). Will take a look at AHK as well. I thought about em_command, but were under the assumption that an em_command cannot take command line parameters and be used like that. Will look into it more carefully. Thank you indeed!
#155067 Personal licence (March 2007)
hi5
Power Member
Power Member
Posts: 637
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Command line alias?

Post by *hi5 »

Assuming you want to launch it from TC: There are TC environment variables such as %commander_path% so you could use a relative path to your tool %commander_path%\..\path\to\tool.exe ?
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Command line alias?

Post by *tuska »

Profane0360 wrote: 2025-01-31, 18:35 UTC I thought about em_command, but were under the assumption that
an em_command cannot take command line parameters and be used like that.
Yes, it can.
User avatar
beb
Power Member
Power Member
Posts: 579
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: Command line alias?

Post by *beb »

[wdx] Autorun plugin (run commands/set envvars upon TC start):
https://ghisler.ch/board/viewtopic.php?t=32427
autorun.cfg

Code: Select all

# SetEnv <varname> <text>

SetEnv someexe c:\path\to\exe\someexe.exe

SetEnv MyAlias %commander_path%\Plugins\wlx\Imagine\Imagine.exe

SetEnv alias_123 %windir%\explorer.exe

If %AutoRun_OSArch% = 32 Then
SetEnv alias %commander_path%\TOTALCMD.EXE
Else
SetEnv alias %commander_path%\TOTALCMD64.EXE
EndIf
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
User avatar
petermad
Power Member
Power Member
Posts: 15997
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Command line alias?

Post by *petermad »

tuska wrote: 2025-01-31, 22:01 UTC
Profane0360 wrote: 2025-01-31, 18:35 UTC I thought about em_command, but were under the assumption that
an em_command cannot take command line parameters and be used like that.
Yes, it can.
usercmd.ini:

Code: Select all

[em_someexe]
cmd=c:\path\to\exe\someexe.exe %A
wincmd.ini:

Code: Select all

[Alias]
someexe=em_someexe

command line:

Code: Select all

someexe somepar1 somepar2
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Profane0360
Junior Member
Junior Member
Posts: 37
Joined: 2023-08-31, 20:08 UTC

Re: Command line alias?

Post by *Profane0360 »

Thank you!
#155067 Personal licence (March 2007)
Post Reply