This forum uses cookies. Click X button to hide this message. What is stored? / Privacy
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pass COMMANDER_* environment vars when running elevated

 
Post new topic   Reply to topic    Total Commander Forum Index -> TC suggestions (English) Printable version
View previous topic :: View next topic  
Author Message
Guillaume
Junior Member
Junior Member


Joined: 08 Apr 2003
Posts: 78

PostPosted: Tue Apr 10, 2018 11:55 am    Post subject: Pass COMMANDER_* environment vars when running elevated Reply with quote

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
Code:
*%comspec%
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
View user's profile Send private message Send e-mail Visit poster's website
petermad
Power Member
Power Member


Joined: 05 Feb 2003
Posts: 7851
Location: Valsted, Denmark

PostPosted: Wed Apr 11, 2018 12:27 am    Post subject: Reply with quote

Support+++
_________________
#524
Danish Total Commander Translator
TC 9.20 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit. TC 2.91b3 on Android 6.0

Get Extended Total Commander Menus
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 8053
Location: Russian Federation

PostPosted: Wed Apr 11, 2018 1:15 am    Post subject: Reply with quote

I agree it would be great but I don't sure it is possible. We can't use TCMADMIN for starting elevated tasks because it will omit UAC dialog or show TCMADMIN process in UAC dialog instead of real application, and currently I don't know any way of passing variables through elevation mechanism.
_________________
TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message Send e-mail
Guillaume
Junior Member
Junior Member


Joined: 08 Apr 2003
Posts: 78

PostPosted: Wed Apr 11, 2018 8:24 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 8053
Location: Russian Federation

PostPosted: Thu Apr 12, 2018 2:44 am    Post subject: Reply with quote

Well, if you just need to start cmd.exe, you can pass some envvars in first argument list in the Command field:
Code:
Command: *%COMSPEC% /k "set "COMMANDER_DRIVE=%COMMANDER_DRIVE%" & set "COMMANDER_PATH=%COMMANDER_PATH%"
Parameters: & cd /d %P & set commander"

_________________
TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message Send e-mail
Guillaume
Junior Member
Junior Member


Joined: 08 Apr 2003
Posts: 78

PostPosted: Thu Apr 12, 2018 10:08 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
petermad
Power Member
Power Member


Joined: 05 Feb 2003
Posts: 7851
Location: Valsted, Denmark

PostPosted: Thu Apr 12, 2018 11:38 am    Post subject: Reply with quote

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.20 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit. TC 2.91b3 on Android 6.0

Get Extended Total Commander Menus
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Guillaume
Junior Member
Junior Member


Joined: 08 Apr 2003
Posts: 78

PostPosted: Mon Apr 16, 2018 6:31 pm    Post subject: Reply with quote

That oughta work. Thanks! Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC suggestions (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Imprint/Impressum: This site is maintained by Ghisler Software GmbH
Privacy Policy | Datenschutzerklärung | Politique de Confidentialité

Using phpBB © phpBB Group