可以试试自己手动分析,用 Wiztree 看看 |
temp2005 发表于 2022-4-5 07:28 ps命令打进cmd了。 |
不知错在哪了 |
更新了说明。 |
3楼楼主能发个成品吗? |
我想问这么用。 |
ilikeyi 发表于 2022-4-4 21:22 这个怎么用 |
本帖最后由 ilikeyi 于 2022-4-4 22:45 编辑 直接写一个 PowerShell 不就行了? 新建一个名为:Cleanup.ps1 例如保存到:d:\Cleanup.ps1 打开 Terminal 终端,先绕过 PowerShell 权限,运行: Set-ExecutionPolicy -ExecutionPolicy Bypass -Force 直接输入以下命令行,运行: d:\Cleanup.ps1 <# 代码开始处 #> <# .Disk clean-up .磁盘清理 #> Function Cleanup_Disk { $SageSet = "StateFlags0099" $Base = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\" $Locations= @( "Active Setup Temp Folders" "BranchCache" "Downloaded Program Files" "GameNewsFiles" "GameStatisticsFiles" "GameUpdateFiles" "Internet Cache Files" "Memory Dump Files" "Offline Pages Files" "Old ChkDsk Files" "D3D Shader Cache" "Delivery Optimization Files" "Diagnostic Data Viewer database files" "Previous Installations" "Recycle Bin" "Service Pack Cleanup" "Setup Log Files" "System error memory dump files" "System error minidump files" "Temporary Files" "Temporary Setup Files" "Temporary Sync Files" "Thumbnail Cache" "Update Cleanup" "Upgrade Discarded Files" "User file versions" "Windows Defender" "Windows Error Reporting Archive Files" "Windows Error Reporting Queue Files" "Windows Error Reporting System Archive Files" "Windows Error Reporting System Queue Files" "Windows ESD installation files" "Windows Upgrade Log Files" ) Foreach ($item in $Locations) { Set-ItemProperty -Path $($Base+$item) -Name $SageSet -Type DWORD -Value 2 -ea silentlycontinue | Out-Null } <# .Do the clean-up. Have to convert the SageSet number .进行清理。 必须转换 SageSet 编号 #> $Args = "/sagerun:$([string]([int]$SageSet.Substring($SageSet.Length-4)))" Start-Process -Wait "$env:SystemRoot\System32\cleanmgr.exe" -ArgumentList $Args <# .Remove the Stateflags .删除状态标志 #> Foreach ($item in $Locations) { Remove-ItemProperty -Path $($Base+$item) -Name $SageSet -Force -ea silentlycontinue | Out-Null } } <# .WinSxS slimming .WinSxS 瘦身 #> Function Cleanup_SxS { # 清理组件 Dism.exe /online /Cleanup-Image /StartComponentCleanup # 重置替代组件的基础 Dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase # 删除备份文件 Dism.exe /online /Cleanup-Image /SPSuperseded } <# .System logs .系统日志 #> Function Cleanup_System_Log { Get-EventLog -LogName * | ForEach-Object { Clear-EventLog $_.Log } } Cleanup_Disk Cleanup_SxS Cleanup_System_Log |
Dism++x64 |
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.