在电脑用久了容易变慢,其中除上“不小心”被安装了很多软件或插件外,另一重要的原因是我们用电脑遗留下来的垃圾文件,比如操作电脑产生的DLL或PF文件、打开OFFICE产生的临时文件、浏览网页产生的网页文件等。虽然这些操作完全可以用360等工具来清理,但如果我们能否自己写个程序来实现呢?答案是肯定,尤其是在公司加入域环境的很多人共用的电脑上,我们完全可以按需编写需要的功能。这里做一常用的bat程序,仅作抛砖引玉之用。
xp用bat清理系统来及的方法:
1、首先,打开记事本。点击“开始”菜单,在“搜索程序和文件”文本框中输入“notepad”,并按回车,打开记事本:
2、如果你是在XP系统下,或是你的Win7系统优化掉了“搜索程序和文件”功能,则需要点击“运行”命令,并按回车打开记事本:
3、然后,将以下内容复制并粘贴到打开的记事本中:
@ECHO off
color 0a
REM 优化更为彻底——可全自动删除域环境下所有本地帐户下的垃圾文件、自动删除系统更新遗留的补
丁文件
REM 针对家庭使用,增加了系统优化功能——自动判断是否需要优化,减少资源占用
::echo 当前帐户:%username%
ECHO.
ECHO ==本程序用于服务器时具有相当的危险性,请参照本程序源码REM操作!==
ECHO Log和Bak清理部分对于服务器和实验机台请勿使用!
echo 禁止java后台更新程序自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v SunJavaUpdateSched /f >nul 2>nul
echo 禁止Adobe Reader升级程序自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Adobe ARM" /f >nul 2>nul
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Adobe Reader Speed Launcher" /f >nul 2>nul
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Reader_sl /f >nul 2>nul
echo 禁止飞信自启动
reg delete HKEY_LOCAL_user\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Fetion /f >nul 2>nul
echo 禁止系统配置程序员自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v MSConfig /f >nul 2>nul
echo 禁止日语输入法自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v IMJPMIG8.1 /f >nul 2>nul
echo 禁止微软多语言支持自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v IMEKRMIG6.1 /f >nul 2>nul
echo 禁止微软IME输入法组件自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v IMSCMig /f >nul 2>nul
echo 禁止同步自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Synchronization Manager" /f >nul 2>nul
echo 禁止微软拼音输入法2002自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v MSPY2002 /f >nul 2>nul
echo 禁止微软拼音输入法组件自启动
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v PHIME2002A /f >nul 2>nul
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v PHIME2002ASync /f >nul 2>nul
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "Microsoft Pinyin IME Migration" /f >nul 2>nul
TITLE 清理.bak备份文件-谨慎操作!
del /f /s /q %windir%\*.bak
REM 用于服务器时请勿删除日志!-谨慎操作!
TITLE 用于服务器时请勿删除日志!-谨慎操作!
del /f /s /q %systemdrive%\*.log
REM 勿使用rd /s /q %windir%\temp & md %windir%\temp命令,否则服务器服务(如DB)容易出现问题!
del /f/s /q %windir%\temp\*.*
REM 若要清理帮助文件,将下面的::删除即可
rd /s /q "%windir%\help"
ECHO ::1.清理局域网共享痕迹--注册表::
TITLE ::1.清理局域网共享痕迹--注册表::
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\WorkgroupCrawler\Shares" /f >nul 2>nul
ECHO ::2.清理运行或操作历史记录--注册表::
TITLE ::2.清理运行或操作历史记录--注册表::
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\Folder" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.txt" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.rar" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.mp3" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.jpg" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.ini" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.bmp" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.doc" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.eip" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.htm" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.ico" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.inf" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.gif" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.wav" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.xls" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.rm" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\*" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\mp3" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\rm" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\wav" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\bat" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\exe" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\eip" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\ico" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\htm" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU\jpg" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StreamMRU" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{5E6AB780-7743-11CF-A12B-00AA004AE837}\Count" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count" /va /f >nul 2>nul
reg delete "HKCU\Software\WinRAR\ArcHistory" /va /f >nul 2>nul
reg delete "HKCU\Software\WinRAR\DialogEditHistory\ArcName" /va /f >nul 2>nul
reg delete "HKCU\Software\WinRAR\DialogEditHistory\ExtrPath" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\MediaPlayer\Player\RecentFileList" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Microsoft Management Console\Recent File List" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Office\11.0\PowerPoint\Recent File List" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Office\11.0\Excel\Recent File" /va /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Office\11.0\Word\Data" /v "Settings" /f >nul 2>nul
reg delete "HKCU\Software\VMware, Inc." /va /f >nul 2>nul
ECHO ::3.清理IE浏览历史的下拉列表--注册表::
TITLE ::3.清理IE浏览历史的下拉列表--注册表::
reg delete "HKCU\Software\Microsoft\Internet Explorer\TypedUrls" /va /f >nul 2>nul
ECHO ::4.正在清理常见系统垃圾文件,请退出360等程序::
TITLE ::4.正在清理常见系统垃圾文件,请退出360等程序::
del /f /q "%ALLUSERSPROFILE%\Documents\DrWatson\*.*">nul 2>nul
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\thumbs.db
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\system32\dllcache\*.*
del /f /s /q %windir%\prefetch\*.*
cls
ECHO ::5.为安全起见,以下清理操作只对当前登录帐户有效::
TITLE ::5.为安全起见,以下清理操作只对当前登录帐户有效::
del /f /s /q "%tmp%\*.*"
ECHO ::6.清理文件缓存::
TITLE ::6.清理文件缓存::
SFC /purgecache
cls
ECHO ::7.清理系统升级补丁目录::
TITLE ::7.清理系统升级补丁目录::
dir %SystemRoot%\$*$ /ad/b >%SystemRoot%\DirTmp.txt
for /f %%a in (%SystemRoot%\DirTmp.txt) do rd /s /q "%SystemRoot%\%%a"
del /f /q %SystemRoot%\DirTmp.txt
cls
ECHO ::8.清理磁盘错误检测文件::
TITLE ::8.清理磁盘错误检测文件::
dir %SystemDrive%\found.??? /ad/b >%systemDrive%\DirTmp.txt
for /f %%a in (%systemDrive%\DirTmp.txt) do rd /s /q "%systemDrive%\%%a"
del /f /q %systemDrive%\DirTmp.txt
cls
ECHO ::9.正在清理所有(域)帐户下的所有临时文件,请稍候::
TITLE ::9.正在清理所有(域)帐户下的所有临时文件,请稍候::
dir "%SystemDrive%\Documents and Settings\" /ad/b >%SystemDrive%\DirTmp.txt
for /f %%a in (%SystemDrive%\DirTmp.txt) do del /f /s /q "%SystemDrive%\Documents and Settings\%%a\Cookies\*.*"&del /f /s /q "%SystemDrive%\Documents and
Settings\%%a\Recent\*.*"&rd /s /q "%SystemDrive%\Documents and Settings\%%a\Local Settings\History\"&del /f /s /q "%SystemDrive%\Documents and Settings\%%
a\Local Settings\Temp\*.*"&del /f /s /q "%SystemDrive%\Documents and Settings\%%a\Local Settings\Temporary Internet Files\*.*"
del /f /q %SystemDrive%\DirTmp.txt
cls
ECHO ::10.删除系统驱动备份文件,释放空间::
TITLE ::10.删除系统驱动备份文件,释放空间::
rd /s /q %SystemDrive%\swsetup\
ECHO ::11.正在进行系统优化::
TITLE ::11.正在进行系统优化::
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v TkBellExe /f
cls
ECHO ::12.正在进行最后一步——磁盘清理,完成后自动退出::
ECHO 当耗时越长时,说明你系统垃圾越多,请耐心等待程序执行完毕。。。
TITLE ::12.正在进行最后一步——磁盘清理,完成后自动退出::
cleanmgr /sagerun:99
exit
4、再单击记事本中的“文件”菜单,在弹出的菜单中“另存为”命令:
5、最关键的一步:在弹出的“另存为”对话框中,一定要选择“保存类型”为“所有文件”,然后在“文件名”中输入文件名并加上bat程序专用扩展名“.bat”,如下图:
6、至此,清理系统垃圾的bat程序已经制作完成,我们打开保存的目录,并右击这个“Bat清理系统垃圾.bat”程序,从弹出的菜单中选择“以管理员身份运行”(如果是在Vista、win7 or more系统下):
7、注意,如果没有选择“以管理员身份运行”,则程序在执行过程中会显示“拒绝访问”,同时很多垃圾文件将不能清理干净,
8、选择“以管理员身份运行”后,系统弹出“用户帐户控制”对话框,我们选择“是”既可:
9、然后程序即会开始执行:
10、因程序中使用了“reg”命令清理注册表垃圾,所以360安全卫士会弹出危险警告,务必要选择“允许程序的所有操作”,否则注册表垃圾不能被清理:
11、待程序执行完毕后,会自动关闭这个窗口。
【xp系统清理bat】这就跟大家分享完了,如果身边有朋友遇到同样的电脑使用疑问的话,可以将上述教程分享出去。还有其他的windows系统下载后操作的疑问的话,欢迎上系统粉官网查找解决的对策。
电脑软件相关教程