有没有办法使用Powershell2.0清空回收站?
我不想更新Powershell。
发布于 2018-09-04 18:08:50
您可以通过com对象清除回收站。如下所示:
$Shell= New-Object -ComObject Shell.Application
$Bin = $Shell.NameSpace(10)
foreach ($Item in @($Bin.Items())){Remove-item $Item.Path -Force}发布于 2018-09-04 20:43:41
您也可以直接调用SHEmptyRecycleBin Win32函数:
$definition = @'
[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
public static extern uint SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath, uint dwFlags);
'@
$winApi = Add-Type -MemberDefinition $definition -Name WinAPI -Namespace Extern -PassThru
$winApi::SHEmptyRecycleBin(0, $null, 7)所有回收站都将被删除,不显示确认消息,没有进度条,没有声音。
https://stackoverflow.com/questions/52163330
复制相似问题