WAD internal "which" should check for FILEEXIST when using AppPaths entry

Nov 14, 2008
5
0
Hamburg, Germany
Hi,

it's a nice idea to check registry AppPaths as well as %PATH in "which" - in principle.
In practice, the command should check wether a file found via AppPaths really exists before returning it - otherwise you get non-existant returns erroneously left over from old uninstalls... eg if manual uninstall of a product did NOT remove the AppPaths entry.
 

rconn

Administrator
Staff member
May 14, 2008
12,365
150
WAD. The AppPaths check is done in the path search, not by WHICH.

You can make a new feature request in the Suggestions Forum if you want WHICH to add a check for the file existence. (But it means that WHICH will *not* return the same result as if you tried to execute the specified command name -- in the case of a bad AppPaths entry, you'd get an error message from Windows.)
 
Nov 2, 2008
231
2
If apppath is pointing to a non-existant file, you should fix apppath. Programs that use apppath would be disappointed. I use the APPPATH.CPL by Mike Linn to do this. I'm just wondering if there is a cunning trick you can do in tcmd to run an apppath proggie from its name.
 
May 29, 2008
571
4
Groton, CT
If apppath is pointing to a non-existant file, you should fix apppath. Programs that use apppath would be disappointed. I use the APPPATH.CPL by Mike Linn to do this. I'm just wondering if there is a cunning trick you can do in tcmd to run an apppath proggie from its name.
Would you give us a pointer to this applet, please?
 
May 20, 2008
11,424
99
Syracuse, NY, USA
I figured you could probably clean up the AppPaths key with a BTM file. I got this far (and probably won't finish) ... might only need a @REGDELKEY.
upload_2017-7-30_14-18-59.png
 
May 20, 2008
11,424
99
Syracuse, NY, USA
Here's a slightly tidier version.
Code:
v:\> type apppathfix.btm
set apppath=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
do x in /p regdir /s1 %apppath
        set key=%apppath\%@ltrim[" ",%x]
        set target=%@regquery["%key\"]
        if "%target" EQ "-1" iterate
        iff not exist "%target" then
                echo Bogus: Key: %key  @: %target
        endiff
enddo

Code:
v:\> apppathfix.btm
Bogus: Key: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe  @: G:\7Zip\7zFM.exe
Bogus: Key: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\mbam.exe  @: G:\Malwarebytes\mbam.exe
 
May 20, 2008
11,424
99
Syracuse, NY, USA
Find apppath here https://www.gregorybraun.com/ . It comes in an exe too.
Cute app. I looked at it only briefly and it didn't seem to identify bogus entries. I did finish my BTM. Here it is, followed by two examples, one not elevated and one elevated.
Code:
:: CLEANAPPPATH.BTM
set apppath=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
do x in /p regdir /s1 %apppath
        set key=%apppath\%@ltrim[" ",%x]
        set target=%@regquery["%key\"]
        if "%target" EQ "-1" iterate
        iff not exist "%target" then
                echo Bogus key: %key  @: %target^r^n
                echo Here's what's in it:^r^n
                regdir /v /d "%key"
                unset response
                inkey /c /k"yn" ^r^nWould you like to delete this key [YN]? ... ^s %%response
                iff "%response" EQ "y" then
                        if %_elevated NE 1 (echo ^r^nThe session must be elevated to delete a key. & iterate)
                        if %@regdelkey["%key"] EQ 1 (echo Key deleted) else (echo Key was not deleted)
                endiff
        endiff
enddo
upload_2017-7-31_13-4-39.png


upload_2017-7-31_13-5-35.png
 
Similar threads
Thread starter Title Forum Replies Date
fpefpe How to? free (internal) command Support 0
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
T Returning a value from internal Lua scripts to TCC Support 2
rps For loop internal %_for_files variable? Support 2
Joe Caverly Why does TCCRT return VIEW as an internal command? Support 6
F How to? Disable TCC's internal response to Alt-F4 Support 8
vefatica @EVAL's internal precision? Support 9
P Can't disable internal tar, at least in pipes Support 3
M Keywords for commands, functions, internal variables Support 3
D WAD Internal variable _cpu is undefined Support 2
E View (internal command) does nothing now Support 3
D Minor problem. Incorrect value internal var _dir_files Support 7
jbanaszczyk Alias for internal command Support 8
Joe Caverly Internal Lua and require Support 0
R Fixed Internal ZIP command fails to process multiple files Support 3
D Internal variable _tctabs within TCExit Support 9
mikea Questions re: Internal ZIP command Support 5
epement no internal help for 'v' in TCmd v14 Support 6
R Override TCC internal commands Support 2
H [4NT8] Internal Start-command and _? variable Support 5
G 4NT 9.02 _shell internal variable Support 50
vefatica Should it be this slow? Support 14
MickeyF alias terminating before it should Support 3
cgunhouse One of the Focuses of V17 Beta Testing Should Be Command Line Parsing Support 1
T TCTOOLBAR /C & TCTOOLBAR /I should reload toolbar from TCMD.INI, right? Support 1
mfarah Mouse wheel scrolling in TCC. What should we expect? Support 10
vefatica Should Ctrl-C interrupt a COPY? Support 2
x13 Check if process is elevated? Support 11
MikeBaas How to check if label exists? Support 3
gentzel "Check for Updates" appears to be checking for old version Support 2
D check for network tcstart.btm and load if newer Support 3
D Dir History file check Support 18
A Help | Check for updates "old news" Support 13
H Is "Check for updates" supposed to work in v10? Support 1

Similar threads