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,556
167
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
246
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
572
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
12,167
133
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
12,167
133
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
12,167
133
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