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

Aus QBWiki
Zur Navigation springenZur Suche springen
Zeile 3: Zeile 3:
  
  
<syntaxhighlight lang="ps" number="1">
+
<syntaxhighlight lang="shell" line="1">
 
IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
 
IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
 
     Write-Warning "File or directory does not exist."       
 
     Write-Warning "File or directory does not exist."       

Version vom 18. Juni 2019, 08:18 Uhr



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 }