Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Easy way to get the directory where the current TCC.EXE resides?

May
13,000
174
I'm using %@left[-7,%comspec] but that seems kludgy. I looked for an internal variable and didn't find one.
 
Code:
E:\Utils>echo %@path[%_cmdspec]
C:\Program Files\JPSoft\TCMD32\

Joe
 
I think @Joe Caverly's use of _cmdspec vs COMSPEC is better IMO. COMSPEC is just an environment variable that can be changed even though you are running TCC. The internal variable will always point to TCC.
 
If you always start TCC from the same place, the _startpath variable could work too.
 
I think @Joe Caverly's use of _cmdspec vs COMSPEC is better IMO. COMSPEC is just an environment variable that can be changed even though you are running TCC. The internal variable will always point to TCC.
Thanks, @samintz. You're right about that. And thanks @Joe Caverly and @Rodolfo. If I ever used _CMDSPEC it had to be a couple decades ago.

I wrote a BTM to make editing PATH easier ... split it into parts in a tmpfile, edit the file, put it back together again, set it. Is there something built-in to do that? And I wanted to use TCEDIT because everyone has it. I couldn't figure out a nice way to use the internal TCEDIT command and wait for the editor to exit (without getting a second instance of TCC). So I'm using TCEDIT.EXE directly and I needed a path to it. Any ideas on that?

I also thought of /A(ppend) and /P(repend) options for PATH to do a limited version of that without an editor. Good idea? I suppose I could make my BTM do that (optionally).
 
Not a solution, but from 2014...


Joe
 
I assume ESET isn't an option? I use ESET all the time. The downside is cursor movement is terribly slow when you have long paths. But append and prepend are very easy with ESET.
 
Hey @vefatica,
Could you do something like this;
Code:
path /n | tcedit

Modify the path in TCEdit,
save to STDOUT,
and then do something with it?

1713539410688.png


Joe
 
For a lot of these one-off types of things, I use the clipboard.
Code:
path /n | tcedit
do p in @clip: (set newp=%newp;%p)
set PATH=%@right[-1,%newp]
 
For a lot of these one-off types of things, I use the clipboard.
Code:
path /n | tcedit
do p in @clip: (set newp=%newp;%p)
set PATH=%@right[-1,%newp]
I don't follow that. How does anything get into CLIP:?
 
I don't follow that. How does anything get into CLIP:?
You would edit in TCEDIT, then Ctrl+A, Ctrl+C. Then exit TCEDIT. I just showed the steps I take. You would need a waitfor before the do if you were to put that in a BTM or library.
 
You would edit in TCEDIT, then Ctrl+A, Ctrl+C. Then exit TCEDIT. I just showed the steps I take. You would need a waitfor before the do if you were to put that in a BTM or library.
OK, I get it now. That's too much for the user to remember. I have this (so far). No doubt, there will be more changes.

Code:
:: PATHEDIT.BTM
setlocal

if "%1" == "/?" goto syntax
if "%1" == "/A" (shift & goto append)
if "%1" == "/P" (shift & goto prepend)

set before=%temp\pathedit_before.tmp
set after=%temp\pathedit_after.tmp

path /n > %before
start /wait /pgm "%@path[%_cmdspec]\tcedit.exe" %before
:: below, the second replace gets rid of a
:: trailing ';' which could be just left there
tpipe ^
    /input=%before ^
    /output=%after ^
    /replace=0,0,0,0,0,0,0,0,0,\r\n,; ^
    /replace=4,0,0,0,0,0,0,0,0,";\Z",""
set path=%@line[%after,0]
goto done

:append
    :: don't add a second ';' (not really necessary)
    set semicolon=%@if["%@right[1,%path]" == ";",,;]
    set path=%[path]%[semicolon]%1$
goto done

:prepend
    set path=%1$;%path
goto done

:syntax
    echo Usage: PATHEDIT.BTM [[/A(ppend) ^| /P(repend)] string]^r^n
    echo ^tWithout /A or /P, interactive using TCEDIT.EXE
    echo ^tDo not quote string
    echo ^tString can be of the form dir1;dir2[...]
goto done

:done
    endlocal path
 
for those eho use 4nt, tcc, tc, tci, tc34, comspec is set by the previous commmnd peocessor, tci is not a command processor v8.01 and v 35 used in the test.,
 
Why not just Prepend with...
Code:
set PATH=C:\New\Directory\Here;%PATH%
and Append with...
Code:
set PATH=%PATH%;C:\New\Directory\Here
I've done it that way since MS-DOS 4.01.

Edit: I think the discussion (or my interpretation of it) went sideways halfway through the thread and I answered the wrong question...
 
1. Long %PATH% (more specifically, very long environment block, which is most often caused by long %PATH% specifically) could cause programs to crash or behave otherwise unexpectedly.
2. Adding %PATH% entry for each single executable is just silly. Add them to AppPaths registry key and save yourself a couple of brain cells.
3. Wash your hands after toilet. And wash your %PATH% after each program update/install. Many like to add unwanted entries in there.
 

Similar threads

Back
Top