我想删除目录,但进程正在使用它。
mv : Access to the path 'C:\Users\mike\Documents\myapp\node_modules\' is denied.
资源管理器提到dir正在使用中。 Windows Powershell是否等同于fuser
?
请注意,这是一个PowerShell问题。我不想发布GUI应用程序。
答案 0 :(得分:1)
试试这个:
-- network protocol: LPC
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
这会查找文件夹中运行的每个进程。 (或在子目录中)
使用此脚本,您将获得更多信息:
$lockedFolder="C:\Windows\System32"
Get-Process | %{$processVar = $_;$_.Modules | %{if($_.FileName -like "$lockedFolder*"){$processVar.Name + " PID:" + $processVar.id}}}
我认为没有与fuser等效的东西,但是有一个名为handle.exe的工具必须先安装。
PowerShell script to check an application that's locking a file?
答案 1 :(得分:0)
这是@ Eldo.Ob的修改版本,它处理相关文件的优秀答案。
function fuser($relativeFile){
$file = Resolve-Path $relativeFile
foreach ( $Process in (Get-Process)) {
foreach ( $Module in $Process.Modules) {
if ( $Module.FileName -like "$file*" ) {
$Process | select id, path
}
}
}
}
使用中:
> fuser .\node_modules\
Id Path
-- ----
2660 C:\Program Files\nodejs\node.exe