我用 SP1 更新了 Win7 盒子,并将浏览器升级到 IE11。我想删除操作不需要的任何文件(即安装文件等),以避免使用 Clonezilla 不必要地存档它们。是否有支持此目标的良好脚本、列表或程序?谢谢
答案1
Windows 7 清理脚本和进程
下面是我过去用来清理的批处理脚本Windows 7的和Windows Vista机器进行成像,所以如果你愿意的话可以尝试一下。
看系统准备并考虑使用它并运行它,一旦机器断电,你将需要用克隆Zilla然后重新启动视窗。
批处理脚本
我一定会仔细查看脚本并注释掉您不想包含在流程中的任何内容,并事先在测试机上进行测试,以确保安全,不会根据您的需要清理或删除任何需要的内容。
.cmd
这是一个批处理脚本,因此只需将其保存到具有或文件扩展名的文本文档中.bat
,并确保右键单击以以管理员身份运行。
我确实知道其中一些过程也是多余的,但我还没有机会清理这些重复的过程,但无论如何,在同一个文件夹等上运行两次删除或清理过程不会有任何坏处。
@ECHO on
TASKKILL /F /IM explorer.exe
ECHO *****""Stopping Windows Services""****
NET STOP /Y "Themes"
NET STOP /Y "Windows Update"
NET STOP /Y "Fax"
NET STOP /Y "Print Spooler"
NET STOP /Y "Remote Registry"
NET STOP /Y "Background Intelligent Transfer Service"
NET STOP /Y "Office Source Engine"
NET STOP /Y "Offline Files"
NET STOP /Y "Secondary Logon"
NET STOP /Y "Java Quick Starter"
NET STOP /Y "IIS Admin"
NET STOP /Y "smart card"
NET STOP /Y "Tablet PC Input Service"
NET STOP /Y "Telephony"
NET STOP /Y "Windows Media Player Network Sharing Service"
NET STOP /Y "Windows Mobile 2003-based device connectivity"
NET STOP /Y "Windows Mobile-based device connectivity"
NET STOP /Y "Cisco Systems, Inc. VPN Service"
NET STOP /Y "Adobe LM Service"
NET STOP /Y "Adobe Flash Player Update Service"
NET STOP /Y "Bluetooth Support Service"
SC CONFIG "Adobe Flash Player Update Service" START= manual
SC CONFIG "Adobe LM Service" START= manual
SC CONFIG "Fax" START= manual
SC CONFIG "Offline Files" START= manual
SC CONFIG "Java Quick Starter" START= manual
SC CONFIG "Tablet PC Input Service" START= manual
SC CONFIG "Windows Media Player Network Sharing Service" START= manual
SC CONFIG "Windows Mobile 2003-based device connectivity" START= manual
SC CONFIG "Windows Mobile-based device connectivity"" START= manual
::Setting Source Directories as Variables
SET SRC1=C:\Users
SET SRC2=AppData\Local\Temp
SET SRC3=AppData\Local\Microsoft\Windows\Temporary Internet Files
SET SRC4=AppData\Local\Microsoft\Windows\History
SET SRC5=AppData\Microsoft\Windows\Cookies
SET SRC6=AppData\Local\Microsoft\Windows\WER
SET SRC7=AppData\Local\Microsoft\Windows\Explorer
SET SRC8=AppData\Local
ECHO ****Deleting User\AppData\Local\Temp Sub-Directories****
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\") DO RMDIR /S /Q "%%Y"
ECHO ***Deleting User\AppData\Local\MS\Windows\Temporary Internet Files***
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
ECHO ***Deleting User\AppDate\Local\MS\Windiws\History Sub-Directories***
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
ECHO **Deleting User\AppData\Local\Microsoft\Windows\Cookies Sub-Directories**
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y"
ECHO **Deleting User\AppData\Local\Microsoft\Windows\WER\ReportArchive & Report Queue**
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC6%\*.*") DO DEL /F /S /Q "%%Y"
ECHO **Deleting User\AppData\Local\Microsoft\Windows\Explorer**
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC7%\*.*") DO DEL /F /S /Q "%%Y"
ECHO ****""Deleting Non-User Temp files and directories""****
RMDIR /S /Q C:\WINDOWS\SoftwareDistribution
DEL /F /S /Q %TEMP%\*.*
DEL /F /S /Q %systemroot%\temp\*.*
DEL /F /S /Q C:\ProgramData\TEMP\*.*
DEL /F /S /Q C:\Windows\Temp\*.*
DEL /F /S /Q %windir%\Temp\*.*
FOR /D %%X IN ("%windir%\temp\*") DO RMDIR /S /Q "%%X"
ECHO **Recreate all %userprofile%\Appdata\Local\Temp\Low directory**
FOR /D %%X IN (%SRC1%\*) DO FOR /D %%Y IN (%%X\%SRC8%) DO MD %%Y\Temp\Low
ECHO **Set security level back up on all %userprofile%\Appdata\Local\Temp\Low directory**
FOR /D %%X IN (%SRC1%\*) DO FOR /D %%Y IN (%%X\%SRC8%) DO ICACLS %%Y\Temp\Low /setintegritylevel (OI)(CI)low
ECHO ** Remove all print jobs that are pendning**
DEL /Q /F "%systemroot%\system32\spool\printers\*.shd"
DEL /Q /F "%systemroot%\system32\spool\printers\*.spl"
::Empty all recycle bins
RD /S /Q C:\recycler
RD /S /Q C:\$RECYCLE.BIN
ECHO *** Turn off Windows hibernation power save setting ***
POWERCFG HIBERNATE OFF
ECHO *** Resize VSS (shadow storage) ***
VSSADMIN RESIZE SHADOWSTORAGE /FOR=C: /ON=C: /MAXSIZE=1GB
ECHO *** Set disk cleanup parameters to clean and then clean after being set ***
CLEANMGR /D c: /SAGESET:100
PAUSE
CLEANMGR /SAGERUN:100
ECHO *** Flush DNS ***
IPCONFIG /FLUSHDNS
ECHO *** Reset TCP/IP ***
NETSH INT IP RESET
ECHO *** Reset Winsock ***
NETSH WINSOCK RESET CATALOG
explorer.exe
GOTO EOF
Dism 命令
笔记: 如果出现错误 1260,则可能意味着您在组策略中禁用了系统还原或类似功能。因此,只需启用系统还原,然后从管理员提升的命令提示符重新运行这些命令。此外,您可能需要CD /D "C:\Windows\System32"
在运行以下每个命令之前运行。
以下命令将卸载所有以前版本的组件,而无需计划任务的 30 天宽限期:
DISM.exe /online /Cleanup-Image /StartComponentCleanup
以下命令将删除卸载服务包所需的文件。运行此命令后,您将无法卸载任何当前安装的服务包:
DISM.exe /online /Cleanup-Image /SPSuperseded
以下命令将删除每个组件的所有旧版本。完成后,您将无法卸载任何当前安装的服务包或更新:
DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase\
来源