English 中文(简体)
Force Remove a Folder in use using Powerhell
原标题:Force Remove a Folder in-use using Powershell

我撰写了一份文字,最终删除了所有相关档案,删除了自己的内容,从而自行销毁了这些档案,然后,它本应删除其中的夹。

我尝试了关闭视窗探测器的若干办法,通过积极程序进行搜索,并杀害任何相关过程,但尽管能够自行销毁文字,仍不能成功删除。

Set-Location -Path $PSScriptRoot

Remove-Item -Path $PSScriptRootMobile -Force -Recurse

Remove-Item -Path $PSScriptRootNoMobile -Force -Recurse

Remove-Item -Path $MyInvocation.MyCommand.Source -Force -Recurse

Set-Location ..

Remove-Item $foldername -Force -Recurse

The last line throws an error that "The process cannot access the file...because it is being used by another process".

任何想法?

问题回答

这也许不是你现在可能期望的答案,而是把它放在一边,这样,如果有人走到这个read子里,就会有帮助。

在同事的帮助下,我发现档案在编辑或一些其他用户机器上公开,然后在删除档案方面遇到问题。 我必须遵循以下文件,以发现谁在档案中公开,然后关闭这些档案,并试图删除操作,而此时它按预期行事。 请找到文件,说明谁会公开你试图删除的档案。

https://techgoeasy.com/how-to-tell-who-has-a-file-open-in-windows/





相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Run a program from PowerShell with timeout

I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.

How to transpose data in powershell

I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

热门标签