Powershell which process is using a file
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. How to know which processes are using the specified file Ask Question. Asked 4 years, 4 months ago. Active 4 years, 4 months ago.
Viewed 8k times. PS:this is my powershell version:. Improve this question. Did you do any research at all? The downside is that this only works for files that are remotely accessed. Windows has a built-in utility named openfiles that can help list what files are in use and disconnect them. At first glance, it looks perfect for your needs!
You can even wrap this within a PowerShell function to ease the querying and disconnecting of files. This objects list is what actually maintains the list of handles that are in use and enables openfiles to query that information. The downside to turning this feature on is that there is a slight performance hit, which depending on your system, may not be worth the utility of using this tool. Using that information, you can then disconnect a file to unlock it.
Due to the performance hit you may incur with enabling the maintain objects list capability, it might not be worthwhile for your needs. Because of that, other solutions may be needed. Sysinternals is known for the many useful and nearly essential IT tools that they make. Some time ago, Sysinternals was acquired by Microsoft, and you can download and use these well-supported tools for yourself.
Conveniently, there is an application named handles that provides exactly what you are looking for! With administrative privileges: handle. Rafael Rafael 10 10 silver badges 20 20 bronze badges. David R. WalterY WalterY 15 1 1 bronze badge. This indicates whether the file is locked or not, but doesn't give the application that's locking the file. Additionally: it will actually create a new file if it doesn't already exist — monojohnny. Not to mention is copies Jordijs answer.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked 4. See more linked questions. Related Hot Network Questions. Question feed.
When you use this parameter, this cmdlet returns a ProcessModule object System. ProcessModule , not a process object. When you use both the Module and FileVersionInfo parameters in the same command, this cmdlet returns a FileVersionInfo object with information about the file version of all modules. Specifies one or more processes by process name. You can type multiple process names separated by commas and use wildcard characters.
The parameter name "Name" is optional. Process, System. FileVersionInfo, System. By default, this cmdlet returns a System. Process object. If you use the FileVersionInfo parameter, it returns a System.
FileVersionInfo object. ProcessModule object. Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services. Privacy policy. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info.
0コメント