Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Locksmith - command line version #28529

Closed
Langenbacher opened this issue Sep 13, 2023 · 10 comments
Closed

File Locksmith - command line version #28529

Langenbacher opened this issue Sep 13, 2023 · 10 comments
Labels
Idea-Enhancement New feature or request on an existing product Product-File Locksmith Refers to the File Locksmith utility Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@Langenbacher
Copy link

Description of the new feature / enhancement

Make a command line version of file locksmith so it can be use in batch files.

Scenario when this would be used?

I have a batch file to open an excel file, but only if it is not already open.
And after I open the excel file, my batch file waits for it to finish before doing more stuff.

because of the quirky way excel works when it has multiple files open, neither "start /wait" nor C:\Windows\System32\tasklist.exe can do the job.

Supporting information

"C:\Windows\System32\openfiles.exe /query" takes way too long.

"lsof" is a command in various flavors of unix that is like what I want.
https://man7.org/linux/man-pages/man8/lsof.8.html

Lot's of other people want this too, as google will show you.
https://www.google.com/search?q=how+to+check+from+command+line+if+a+given+file+is+open+by+any+process

@Langenbacher Langenbacher added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Sep 13, 2023
@TheJoeFin TheJoeFin added Idea-Enhancement New feature or request on an existing product Product-File Locksmith Refers to the File Locksmith utility and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Sep 13, 2023
@lwahonen
Copy link

lwahonen commented Sep 21, 2023

I needed this acutely, so I added it to my fork ( https://github.com/lwahonen/PowerToys ). I'm happy to help get this merged upstream.

Usage:

"PowerToys.FileLocksmithUI.exe" <options> <files>

Options implemented:

/list Dump all current locks to the console
/wait Only quit after all the locks to a file are gone
/kill Try to kill every process holding a lock to the files listed
/quit Close FileLocksmith after processing other options

For example

image

@lwahonen
Copy link

Ended up making a separate project for the console tool, updated my repo. Not sure how to get the ConsoleSmith.exe packed in the installer, but I'm happy to work with someone more knowledgeable

@crutkas
Copy link
Member

crutkas commented Mar 25, 2024

I would see if we couldn't just do this inside the UI and maybe adjust the UI exe name personally.

Big feedback here would be to if there is an alternative to "kill"

@lwahonen
Copy link

As I said in the other issue: Offering a command-line interface from a program built with subsystem:windows is a headache. You can reattach to the console that started you, but that still breaks things such as piping the output to a file - and scripts often redirect output of tools for reporting / further processing.

I'm very happy if someone has a magic trick in their back pocket that can be used to:

-Not show an extra console window when the application is started via icon
-Output text to cmd if the application is started from the command line
-Have said output be available for piping to files / other tools.

As to your other point, I'm happy to rename the command. Would terminate work better? That seems to be the term often used in Win32 APIs such as TerminateThread

@cow1337killer3
Copy link

Push it out the door the world needs it!

@lwahonen
Copy link

Push it out the door the world needs it!

I'm waiting for @crutkas to either suggest a way to integrate the command-line to the existing UI, or accept that the CLI is a separate tool.

@PolarGoose
Copy link

@Langenbacher,
There are already existing console tools for that:

Would they work for you?

@cow1337killer3
Copy link

cow1337killer3 commented May 20, 2024

Moving discussion to PolarGoose/Handle2#2

@crutkas
Copy link
Member

crutkas commented Sep 6, 2024

/dup #22315

Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service microsoft-github-policy-service bot added the Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea-Enhancement New feature or request on an existing product Product-File Locksmith Refers to the File Locksmith utility Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
Status: Done
Development

No branches or pull requests

6 participants