Can someone help me write a em command to add the selected folder to the path environment variable?

English support forum

Moderators: Hacker, petermad, Stefan2, white

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

Re: Can someone help me write a em command to add the selected folder to the path environment variable?

Post by *petermad »

Code: Select all

[em_addtopath]
cmd=%COMSPEC% /C
param=path %%PATH%%;%P%N
But it will only work for that cmd session, so any additional commands has to be run from the params line.


This em_command will add the folder under the cursor to the path env. and start a new instance of TC that uses that path setting.

Code: Select all

[em_addtopath_innewtc]
cmd=%COMSPEC% /C
param=path %%PATH%%;%P%N && %X start "" "%%COMMANDER_EXE%%" /N /P /A /i="%%COMMANDER_INI%%" %P%N* %T%M*
If you don't want a new (extra) instance of TC you can close the old instance automatically:

Code: Select all

[em_addpatc_restarttc]
cmd=em_addtopath_innewtc, cm_Exit
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
User avatar
nsp
Power Member
Power Member
Posts: 1919
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Can someone help me write a em command to add the selected folder to the path environment variable?

Post by *nsp »

What is your goal ?
Do you want to edit global path, user path ?
If you want to keep your change for next time use setx command.

For global path, you will have to use the SETX comnand as admin :

Code: Select all

TOTALCMD#BAR#DATA
*%comspec% /C
setx /m PATH "%P;%%PATH%%"
wcmicons.dll,34



-1
For user path just use setx command without compsec nor admin:

Code: Select all

TOTALCMD#BAR#DATA
setx 
/m PATH "%P;%%PATH%%"
wcmicons.dll,34



-1
If you need to refresh environment in an opened console, you can use refreshenv script.
Post Reply