View previous topic :: View next topic |
Author |
Message |
Guillaume Junior Member


Joined: 08 Apr 2003 Posts: 78
|
Posted: Tue Apr 10, 2018 11:55 am Post subject: Pass COMMANDER_* environment vars when running elevated |
|
|
TC has the brilliant feature to run programs as Administrator by putting an asterisk in front of the command.
In light of using this with the command I think it would be great if Total Commander could also pass COMMANDER_DRIVE, COMMANDER_EXE, COMMANDER_INSTANCE and
COMMANDER_PATH to this elevated command prompt. Currently, it only does so with non-elevated command prompts, unless TC itself is run as Administrator (which I prefer not to do). |
|
Back to top |
|
 |
petermad Power Member


Joined: 05 Feb 2003 Posts: 7541 Location: Valsted, Denmark
|
Posted: Wed Apr 11, 2018 12:27 am Post subject: |
|
|
Support+++ _________________ #524
Danish Total Commander Translator
TC 9.12 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit. TC 2.90 on Android 6.0
Get Extended Total Commander Menus |
|
Back to top |
|
 |
MVV Power Member


Joined: 03 Aug 2008 Posts: 7980 Location: Russian Federation
|
|
Back to top |
|
 |
Guillaume Junior Member


Joined: 08 Apr 2003 Posts: 78
|
Posted: Wed Apr 11, 2018 8:24 am Post subject: |
|
|
Yeah I understand and feared such a thing, too.
It wouldn't be necessary if I could pass these variables inside the Parameters field, though. For instance, if I could pass the TC path so that TC automatically expands that to the actual path, all would be fine. Unfortunately, putting "%commander_path%" in Parameters results in %C expanded + "ommander_path%", while "%%commander_path%%" requires the environment variable.
I suppose it would be a much easier fix to make the environment variables available in the Parameters field between single percentage characters, so that TC first expands them. |
|
Back to top |
|
 |
MVV Power Member


Joined: 03 Aug 2008 Posts: 7980 Location: Russian Federation
|
|
Back to top |
|
 |
Guillaume Junior Member


Joined: 08 Apr 2003 Posts: 78
|
Posted: Thu Apr 12, 2018 10:08 am Post subject: |
|
|
Shoot, I knew I was missing something. I didn't realize in this case that parameters were allowed in the Command field, too... I must've used it sometimes, it's literally in the Help file ("You can also specify fixed parameters here.")
Thanks for bringing this to my attention again! I think I can pretty much realize everything that instigated this topic. |
|
Back to top |
|
 |
petermad Power Member


Joined: 05 Feb 2003 Posts: 7541 Location: Valsted, Denmark
|
Posted: Thu Apr 12, 2018 11:38 am Post subject: |
|
|
Here is a workaround:
Make these two commands in your usercmd.ini:
Code: | [em_saveenvironment]
cmd=%COMSPEC% /C set COMMANDER_ > %TEMP%\environment.tmp
iconic=1
[em_openenvironment]
cmd=*%COMSPEC% /C (for /F %i in (%TEMP%\environment.tmp) do set %i)
param=&& Start /D"%P" |
Make this button:
Code: | TOTALCMD#BAR#DATA
em_saveenvironment,cm_wait 100,em_openenvironment
%COMSPEC%
Command Prompt as Administrator (with transferred environment)
-1 |
Quote: | To make the button:
1. Mark the green text above (including TOTALCMD#BAR#DATA in the first line and -1 in the last line).
2. Copy it to the ClipBoard (Ctri+C).
3. Right click on TC's buttonbar and choose "Paste". |
_________________ #524
Danish Total Commander Translator
TC 9.12 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit. TC 2.90 on Android 6.0
Get Extended Total Commander Menus |
|
Back to top |
|
 |
Guillaume Junior Member


Joined: 08 Apr 2003 Posts: 78
|
Posted: Mon Apr 16, 2018 6:31 pm Post subject: |
|
|
That oughta work. Thanks!  |
|
Back to top |
|
 |
|