Who locked this file/folder?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
NotNull
Posts: 5260
Joined: Wed May 24, 2017 9:22 pm

Who locked this file/folder?

Post by NotNull »

If you want to know which program locked a file/folder so it can't be deleted, there are several specialized tools available.
But did you know you can use Everything 1.5 for this too?

Wrote it over a year ago, but had only 3 lock-ups during that time, so it needs more (broader) testing.


How to use?

When a file can't be deleted (for example):
  • SHIFT-Right-click the file
    - or -
    SHIFT-Right-click an empty part in Explorer (or other file manager)
    - or -
    SHIFT-Right-click the foldername
  • Select Who opened this?
  • The Opened By column shows the programs that opened this folder.
FWIW: I got the best resulkts using SHIFT-Right-click an empty part in Explorer (or other file manager)



Installation
  • Save OpenedBy.cmd on your disk
  • Change the path to Everything(64).exe if needed.Currently:

    Code: Select all

    	set EverythingEXE=C:\Program Files\Everything 1.5a\Everything64.exe
  • Run OpenedBy.cmd
    This will install the context menu entries
  • Done!
Uninstall
  • Run OpenedBy.cmd
    This will remove the context menu entries
  • Done!


2023-07-11 00_27_43-Settings.png
2023-07-11 00_27_43-Settings.png (146.56 KiB) Viewed 16273 times



OpenedBy.cmd

Code: Select all

@echo off & setlocal enabledelayedexpansion
rem echo on
cls



:: ===============================================
::
::				SETTINGS
::
:: ===============================================


::-----------------------------------------------
::	Location of Everything.exe (WITHOUT surrounding quotes)
::-----------------------------------------------

	rem set EverythingEXE=C:\Tools\Everything\Everything64.exe
	set EverythingEXE=C:\Program Files\Everything 1.5a\Everything64.exe
	
::-----------------------------------------------
::	Instance used for Everything (if not the default 1.5a or none)
::-----------------------------------------------

	rem set EverythingEXE=C:\Tools\Everything\Everything64.exe
	set Instance=
	
	



:: ===============================================
::
::				MAIN
::
:: ===============================================


::_______________________________________________
::
::				INIT
::_______________________________________________
::

	If not defined ICON set ICON=%EverythingEXE%



::_______________________________________________
::
::				ACTION!
::_______________________________________________
::

	set INSTALLED=0

 	REG.exe query "HKCU\Software\Classes\Directory\Shell\OpenedBy" 2>nul >nul && set "INSTALLED=1"
	
	If [%INSTALLED%]==[1] (
		REG DELETE "HKCU\Software\Classes\Directory\Shell\OpenedBy" /f 2>nul >nul
		REG DELETE "HKCU\Software\Classes\Directory\Background\Shell\OpenedBy" /f 2>nul >nul
		REG DELETE "HKCU\Software\Classes\*\Shell\OpenedBy" /f 2>nul >nul
		
		mode 75,15
		color 1F
		echo.
		echo.
		echo.
		echo.		OpenedBy context menu entry REMOVED
		echo.
		echo.		Re-run "%~nx0" to install again.
		echo.
		echo.
		pause
	EXIT /B
	)


::	The following will only get executed when NOT installed


::-----------------------------------------------
::	Add contextmenu to registry for DIRECTORIES
::-----------------------------------------------
		reg.exe add "HKCU\Software\Classes\Directory\Shell\OpenedBy" /v "Extended" /D ""
		reg.exe add "HKCU\Software\Classes\Directory\Shell\OpenedBy" /v "MuiVerb" /D "Who opened this?"
		reg.exe add "HKCU\Software\Classes\Directory\Shell\OpenedBy" /v "Icon" /D "\"%ICON%\""
		reg.exe add "HKCU\Software\Classes\Directory\Shell\OpenedBy\Command" /ve /D "\"%EverythingEXE%\"  -instance \"%INSTANCE%\"  -s*  \"%%1\"   opened-by:  columns:Name,opened-by,dm,Path"

::-----------------------------------------------
::	Add background contextmenu to registry for DIRECTORIES
::-----------------------------------------------
		reg.exe add "HKCU\Software\Classes\Directory\Background\Shell\OpenedBy" /v "Extended" /D ""
		reg.exe add "HKCU\Software\Classes\Directory\Background\Shell\OpenedBy" /v "MuiVerb" /D "Who opened this?"
		reg.exe add "HKCU\Software\Classes\Directory\Background\Shell\OpenedBy" /v "Icon" /D "\"%ICON%\""
		reg.exe add "HKCU\Software\Classes\Directory\Background\Shell\OpenedBy\Command" /ve /D "\"%EverythingEXE%\"  -instance \"%INSTANCE%\"  -s*  \"%%V\"   opened-by:  columns:Name,opened-by,dm,Path"


::-----------------------------------------------
::	Add contextmenu to registry for FILES
::-----------------------------------------------
		reg.exe add "HKCU\Software\Classes\*\Shell\OpenedBy" /v "Extended" /D ""
		reg.exe add "HKCU\Software\Classes\*\Shell\OpenedBy" /v "MuiVerb" /D "Who opened this?"
		reg.exe add "HKCU\Software\Classes\*\Shell\OpenedBy" /v "Icon" /D "\"%ICON%\""
		reg.exe add "HKCU\Software\Classes\*\Shell\OpenedBy\Command" /ve /D "\"%EverythingEXE%\"  -instance \"%INSTANCE%\"  -s*  \"%%1\"   opened-by:  columns:Name,opened-by,dm,Path"


	::	(Not checking if succeeded)
	
		mode 75,15
		color 2F
		echo.
		echo.
		echo.		OpenedBy context menu entry INSTALLED
		echo.
		echo.		Re-run "%~nx0" to remove.
		echo.
		echo.
		pause
	EXIT /B

therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: Who locked this file/folder?

Post by therube »

Just what is "locked"?
I take it is different from "opened"?
(Or is my search different from what you're using?)
.
Everything - Openby Locked.png
Everything - Openby Locked.png (53.35 KiB) Viewed 16217 times
horst.epp
Posts: 1345
Joined: Fri Apr 04, 2014 3:24 pm

Re: Who locked this file/folder?

Post by horst.epp »

Opened is not locked, as a program can set to share the file with others.
The current Version of Microsoft PowerToys contains the LockSmith module
which delivers a context menu entry "What's using this file".
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: Who locked this file/folder?

Post by therube »

So I can "lock" a file, but I'm still not getting anything turning up in 'Open By' (using:
columns:Name,opened-by lockedfile
)?

(powershell)
[System.io.File]::Open('c:\myfile.txt', 'Open', 'Read', 'None')
Is that "lock" again different from locked?
.
Everything - Openby Powershell.png
Everything - Openby Powershell.png (3.83 KiB) Viewed 16207 times
NotNull
Posts: 5260
Joined: Wed May 24, 2017 9:22 pm

Re: Who locked this file/folder?

Post by NotNull »

Opened is indeed not the same as locked.
But the other way around: if you encounter a locked file/folder, you can check who opened it. The 'offender' will likely be among these suspects.
eswul62
Posts: 95
Joined: Wed Jul 31, 2013 6:07 am

Re: Who locked this file/folder?

Post by eswul62 »

Maybe you could give 'Lockhunter" a try
https://lockhunter.com/download.htm

I use the free, portable version, it helped me out many times.

SnagIt-02082023 101848.png
SnagIt-02082023 101848.png (89.48 KiB) Viewed 15342 times
letmeindude
Posts: 15
Joined: Sat Jun 07, 2014 7:53 am

Re: Who locked this file/folder?

Post by letmeindude »

Thank you NotNull for making this. Needed it moments ago and it worked. Why use another app when Everything can do it.
skan
Posts: 11
Joined: Wed Aug 12, 2015 8:40 pm

Re: Who locked this file/folder?

Post by skan »

eswul62 wrote: Wed Aug 02, 2023 8:33 am Maybe you could give 'Lockhunter" a try
https://lockhunter.com/download.htm

I use the free, portable version, it helped me out many times.


SnagIt-02082023 101848.png
What happens if I unlock the file locked by everything? Will this operation crash the everything program?

Anyway, Everything should not lock any file.
void
Developer
Posts: 15352
Joined: Fri Oct 16, 2009 11:31 pm

Re: Who locked this file/folder?

Post by void »

Typically, Everything will open files with shared access.

What type of file is Everything locking? -Eg: an image

Are you showing previews/thumbnails?



Unlocking the file should be fine.
Post Reply