Powershell: Find process that locks a file: Unterschied zwischen den Versionen

Aus QBWiki
Zur Navigation springenZur Suche springen
Zeile 2: Zeile 2:
  
  
 +
Uses the <openfiles> command to find a file-locking process
 +
 +
activate openfiles
 +
<syntaxhighlight lang="shell">
 +
openfiles /local on
 +
</syntaxhighlight>
  
 
<syntaxhighlight lang="shell" line="1">
 
<syntaxhighlight lang="shell" line="1">

Version vom 18. Juni 2019, 08:20 Uhr


Uses the <openfiles> command to find a file-locking process

activate openfiles

openfiles /local on
1 IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
2     Write-Warning "File or directory does not exist."       
3 }
4 Else {
5     $LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath"""
6     Write-Host $LockingProcess
7 }