Can you add a cm command to restart TC?

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Fla$her
Power Member
Power Member
Posts: 2247
Joined: 2020-01-18, 04:03 UTC

Re: Can you add a cm command to restart TC?

Post by *Fla$her »

2monarch-lfv
I remember. Have you not read my answer to this yet?

P. S.: In vain you wedged in. I'm afraid the author won't see my request.
Overquoting is evil! 👎
sirksel
Junior Member
Junior Member
Posts: 61
Joined: 2013-04-24, 10:24 UTC

Re: Can you add a cm command to restart TC?

Post by *sirksel »

ghisler(Author) wrote: 2022-10-04, 16:22 UTC Total Commander 10.52 RC1 is available now! CM_EXIT now supports the following parameters:
0 or no parameter: Just exit.
Or sum of:
1: Exit and restart Total Commander
2: Exit and restart, and switch between 32-bit and 64-bit versions (note: 2 and 3 do the same thing)
4: Save directories, tabs and panels (brief, full etc.) even when disabled in settings
Mr. Ghisler, I love this new addition! Could there also be a parameter 8 that switches between admin-elevated and non-elevated mode? Is that easy to do? I know there are workarounds to do it, but it seems like it fits so nice right here!

EDIT: Maybe I spoke to soon about there being a workaround. Are there actually workarounds to do restart elevated? I'm having trouble using the %COMMANDER_PATH% and %COMMANDER_INI% to launch the second window elevated because they don't exist in the elevated session. Hmmm.... has anyone done this without hard-coding the path names?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Can you add a cm command to restart TC?

Post by *ghisler(Author) »

In RC2, parameter 8 does something else now:
8: Pass current left and right directory and file under cursor to new instance

I have considered the elevated option, but the switch from elevated to non-elevated is a hack and mess. You can define an em_command to run TC elevated, by putting a * at the beginning of the command line.
Author of Total Commander
https://www.ghisler.com
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Can you add a cm command to restart TC?

Post by *Stefan2 »

sirksel wrote: 2022-10-11, 04:22 UTC

Mr. Ghisler, I love this new addition! Could there also be a parameter 8 that switches between admin-elevated and non-elevated mode? Is that easy to do? I know there are workarounds to do it, but it seems like it fits so nice right here!

EDIT: Maybe I spoke to soon about there being a workaround. Are there actually workarounds to do restart elevated? I'm having trouble using the %COMMANDER_PATH% and %COMMANDER_INI% to launch the second window elevated because they don't exist in the elevated session. Hmmm.... has anyone done this without hard-coding the path names?

%COMMANDER_PATH% and such env vars are only available inside of TC and programs started from TC.


You can use this copy&paste button-code

Code: Select all

TOTALCMD#BAR#DATA
*"%COMMANDER_EXE%"
%Z/N %X"%P" "%T"
%COMMANDER_EXE%
Launch 2nd TC instance e.g. as ADMIN

0
-1
to launch currently running %COMMANDER_EXE% again,
but due to the leading * , you will be prompted
so you could change user or enter admin credentials or just launch TC as is as second instance.







 
User avatar
white
Power Member
Power Member
Posts: 4596
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Can you add a cm command to restart TC?

Post by *white »

ghisler(Author) wrote: 2022-10-11, 06:52 UTC I have considered the elevated option, but the switch from elevated to non-elevated is a hack and mess. You can define an em_command to run TC elevated, by putting a * at the beginning of the command line.
How about allowing one direction by allowing *cm_Exit to restart elevated?
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Can you add a cm command to restart TC?

Post by *petermad »

How about allowing one direction by allowing *cm_Exit to restart elevated?
I like that idea :-)
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Can you add a cm command to restart TC?

Post by *petermad »

Stefan2 wrote: 2022-10-11, 07:08 UTC You can use this copy&paste button-code

Code: Select all

TOTALCMD#BAR#DATA
*"%COMMANDER_EXE%"
%Z/N %X"%P" "%T"
%COMMANDER_EXE%
Launch 2nd TC instance e.g. as ADMIN

0
-1

I prefer this modification:

Code: Select all

TOTALCMD#BAR#DATA
*%COMMANDER_EXE% /N /P /A /i="%COMMANDER_INI%"
%Z%X %P%N* %T%M*
%COMMANDER_EXE%
Launch 2nd TC instance e.g. as ADMIN
It will place the cursor in the file panels on the file/folder it was on in the current TC, and it will use the same ini file as the current TC, in case TC was started with another ini file than the default.
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
sirksel
Junior Member
Junior Member
Posts: 61
Joined: 2013-04-24, 10:24 UTC

Re: Can you add a cm command to restart TC?

Post by *sirksel »

@stefan2 and @petermad, thanks for the button code!

Mr. Ghisler, I agree with @white that even just one way (non-elevated to elevated) would be fantastic. I can get this to work with the workaround, but I seem to be losing all my custom menus and stuff when I make a custom command and map it to a keystroke (that is not a toolbar button). I think it has to do with the environment variables not yet existing in the new session. I'm experimenting with the button code the others volunteered to see if I can get the workaround to work.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Can you add a cm command to restart TC?

Post by *Stefan2 »

petermad wrote: 2022-10-11, 10:28 UTC
I prefer this modification:


Thanks for the update ;-)





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

Re: Can you add a cm command to restart TC?

Post by *petermad »

2sirksel
I think it has to do with the environment variables not yet existing in the new session
Does that mean that you are starting your TC from a batch file where you set environment variables?
The "%COMMANDER_INI%" variable in the button command IS recognized.
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
sirksel
Junior Member
Junior Member
Posts: 61
Joined: 2013-04-24, 10:24 UTC

Re: Can you add a cm command to restart TC?

Post by *sirksel »

2petermad

Thanks for the help. If it works in a button, does that mean it should also work in a em_command that is assigned in a custom menu or [shortcuts]? All my setup is around keystrokes rather than buttons, but I thought what would work in a button would work in a custom command definition. I'll mess with it a bit more to see what's going on, when I get home from work tonight.

(I have a custom ftp.ini so I have to use some relative path references since there isn't, at least to my knowledge, a %COMMANDER_FTP% environment var. Maybe when I remove some of those complications when I get home from work tonight, it will work for me as a custom command.) Thanks again.
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Can you add a cm command to restart TC?

Post by *petermad »

If it works in a button, does that mean it should also work in a em_command that is assigned in a custom menu or [shortcuts]?
Yes

Code: Select all

TOTALCMD#BAR#DATA
*%COMMANDER_EXE% /N /P /A /i="%COMMANDER_INI%"
%Z%X %P%N* %T%M*
%COMMANDER_EXE%
Launch 2nd TC instance e.g. as ADMIN
equals:

Code: Select all

[em_openTCasAdmin]
cmd=*%COMMANDER_EXE% /N /P /A /i="%COMMANDER_INI%"
param=%Z%X %P%N* %T%M*
button=%COMMANDER_EXE%
menu=Launch 2nd TC instance e.g. as ADMIN
(I have a custom ftp.ini so I have to use some relative path references since there isn't, at least to my knowledge, a %COMMANDER_FTP% environment var. Maybe when I remove some of those complications when I get home from work tonight, it will work for me as a custom command.) Thanks again.
Use: "%COMMANDER_INI%\..\my_ftp.ini"

for example:

Code: Select all

[em_openTCasAdmin]
cmd=*%COMMANDER_EXE% /N /P /A /i="%COMMANDER_INI%" /f="%COMMANDER_INI%\..\my_ftp.ini"
param=%Z%X %P%N* %T%M*
button=%COMMANDER_EXE%
menu=Launch 2nd TC instance e.g. as ADMIN
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Can you add a cm command to restart TC?

Post by *petermad »

white wrote:How about allowing one direction by allowing *cm_Exit to restart elevated?
history.txt wrote:14.10.22 Added: CM_EXIT: Add 16 to parameter to restart with full administrator rights (elevated) (32/64)
Confirmed working in TC 10.52rc3 - so what more can we wish for...?
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2247
Joined: 2020-01-18, 04:03 UTC

Re: Can you add a cm command to restart TC?

Post by *Fla$her »

petermad wrote: 2022-10-14, 14:08 UTCso what more can we wish for...?
Should I repeat my requests? Or will you find it yourself? ;)
Overquoting is evil! 👎
sirksel
Junior Member
Junior Member
Posts: 61
Joined: 2013-04-24, 10:24 UTC

Re: Can you add a cm command to restart TC?

Post by *sirksel »

2petermad

Thanks so much for all the help. I didn't have the button parameters exactly lined up correctly with the custom command parameters. Your detailed parallel of the two approaches allowed me to see that clearly. On the ftp.ini issue, that relative directory resolution worked great for me. Thank you.

2ghisler

I guess your excellent new changes made it all easier anyhow. I got back from a weekend away and found another pleasant surprise from Mr. Ghisler! Thanks so much for putting that in. Works great in 10.52rc3!
Post Reply