无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
楼主: 鹤冲天
打印 上一主题 下一主题

那位老师有些批处理的实例能否贴出来让偶等小鸟学习学习!

[复制链接]
91#
 楼主| 发表于 2007-2-3 00:29:54 | 只看该作者
我把这段时间学习的东西总结了下,开始自己学着写批处理。当然还是主要干些复制粘贴的活,呵呵,创造性的东西还不行,脑子还是比较空,在接下来的日子里偶还有很多的东西要学习!
偶把代码放上来,希望大家给看看,能否精简压缩下,或者还有其他的方法能实现类似的功能,希望大家表嫌弃俺多帮帮俺啊!:lol
特别是能把清理垃圾的代码重复利用。CALL和GOTO偶看了看,无奈才疏学浅没有找到合适的解决方案,希望大家帮帮偶!
因帖子限制长度故没全文帖出!
@echo off
TITLE winodws XP 优化处理文件 【鹤冲天】
COLOR 0A
CLS
:start
cls
echo.
echo "全自动精简优化XP"
echo.
echo.
echo                    初级优化XP-----------1
echo                    中级优化XP-----------2
echo                    高级优化XP-----------3
echo.
echo;
set /p ii=请添入相应的修改项目(1 or 2 or 3):
set ii=%ii:~0,1%
if "#%ii%"=="#1" goto A
if "#%ii%"=="#2" goto B
if "#%ii%"=="#3" goto C
cls
echo.
echo;
echo:
echo.
echo.
echo            您输入了错误的数字!!!
echo             -_-.-_-.-_-.-_-.-_-
echo.
echo;
echo;
echo;
pause
goto start

:A
@echo off
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo winodws XP 优化处理文件
echo.
echo 正在清除系统垃圾文件,请稍等......
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
sfc /purgecache
sfc /purgecache
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\*.log
del /f /s /q %windir%\*.tmp
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
rd /s /q %temp% & md %temp%
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo 清除系统垃圾完成!
echo.
echo 正在自动对WinXP的服务进行优化...
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
@rem Alerter
@rem 微软: 通知选取的使用者及计算机系统管理警示。如果停止这个服务,使用系统管理@rem 警示的程序将不会收到通知。
@rem 补充: 一般家用计算机根本不需要传送或接收计算机系统管理来的警示(Administrative Alerts),除非你的计算机用在局域网络上
@rem 依存: Workstation
@rem 建议: 已停用
sc config Alerter start= DISABLED
echo.
@rem Application Layer Gateway Service
@rem 微软: 提供因特网联机共享和因特网联机防火墙的第三方通讯协议插件的支持
@rem 补充: 如果你不使用因特网联机共享 (ICS) 提供多台计算机的因特网存取和因特网联机防火墙 (ICF) 软件你可以关掉
@rem 依存: Internt Connection Firewall (ICF) / Internet Connection Sharing (ICS)
@rem 建议: 已停用
sc config ALG start= DISABLED
echo.
@REM Security Center
@REM 监视系统安全设置和配置。
sc config wscsvc start= DISABLED
cls
echo 优化完毕!
goto end
:B
@echo off
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo winodws XP 优化处理文件
echo.
echo 正在清除系统垃圾文件,请稍等......
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
sfc /purgecache
sfc /purgecache
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\*.log
del /f /s /q %windir%\*.tmp
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
rd /s /q %temp% & md %temp%
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo 清除系统垃圾完成!
echo.
echo 正在自动对WinXP的服务进行优化...
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
@rem Alerter
@rem 微软: 通知选取的使用者及计算机系统管理警示。如果停止这个服务,使用系统管理@rem 警示的程序将不会收到通知。
@rem 补充: 一般家用计算机根本不需要传送或接收计算机系统管理来的警示(Administrative Alerts),除非你的计算机用在局域网络上
@rem 依存: Workstation
@rem 建议: 已停用
sc config Alerter start= DISABLED
echo.
@REM Security Center
@REM 监视系统安全设置和配置。
sc config wscsvc start= DISABLED
cls
echo 优化完毕!
goto end
:C
@echo off
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo winodws XP 优化处理文件
echo.
echo 正在清除系统垃圾文件,请稍等......
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
sfc /purgecache
sfc /purgecache
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\*.log
del /f /s /q %windir%\*.tmp
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
rd /s /q %temp% & md %temp%
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo 清除系统垃圾完成!
echo.
echo 正在自动对WinXP的服务进行优化...
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
@rem Alerter
@rem 微软: 通知选取的使用者及计算机系统管理警示。如果停止这个服务,使用系统管理@rem 警示的程序将不会收到通知。
@rem 补充: 一般家用计算机根本不需要传送或接收计算机系统管理来的警示(Administrative Alerts),除非你的计算机用在局域网络上
@rem 依存: Workstation
@rem 建议: 已停用
sc config Alerter start= DISABLED
echo.
@rem Application Layer Gateway Service
@rem 微软: 提供因特网联机共享和因特网联机防火墙的第三方通讯协议插件的支持
@rem 补充: 如果你不使用因特网联机共享 (ICS) 提供多台计算机的因特网存取和因特网联机防火墙 (ICF) 软件你可以关掉
@rem 依存: Internt Connection Firewall (ICF) / Internet Connection Sharing (ICS)
@rem 建议: 已停用
sc config ALG start= DISABLED
@REM Universal Plug and Play Device Host
@REM 为主持通用即插即用设备提供支持。
sc config upnphost start= DEMAND
echo.
@REM Security Center
@REM 监视系统安全设置和配置。
sc config wscsvc start= DISABLED
cls
echo 优化完毕!
:d
@echo off
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo winodws XP 优化处理文件
echo.
echo 正在清除系统垃圾文件,请稍等......
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
sfc /purgecache
sfc /purgecache
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\*.log
del /f /s /q %windir%\*.tmp
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
rd /s /q %temp% & md %temp%
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo 清除系统垃圾完成!
echo.
echo 正在自动对WinXP的服务进行优化...
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
:end
echo.
sfc /purgecache
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo WinXP 的服务进行优化完成!
echo.
echo 正在对 IE 组件修复,注册,优化
echo.
echo 请等待几秒钟......
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
regsvr32 /s actxprxy.dll
echo 完成百分之 10
regsvr32 /s shdocvw.dll
echo 完成百分之 15
regsvr32 /s oleaut32.dll
echo 完成百分之 20
Regsvr32 /s URLMON.DLL
echo 完成百分之 25
Regsvr32 /s mshtml.dll
echo 完成百分之 30
Regsvr32 /s msjava.dll
echo 完成百分之 35
Regsvr32 /s browseui.dll
echo 完成百分之 40
Regsvr32 /s softpub.dll
echo 完成百分之 45
Regsvr32 /s wintrust.dll
echo 完成百分之 50 (优化,请等待)
Regsvr32 /s initpki.dll
echo 完成百分之 55
Regsvr32 /s dssenh.dll
echo 完成百分之 60
Regsvr32 /s rsaenh.dl
echo 完成百分之 65
Regsvr32 /s gpkcsp.dll
echo 完成百分之 70
Regsvr32 /s sccbase.dll
echo 完成百分之 75
Regsvr32 /s slbcsp.dll
echo 完成百分之 85
Regsvr32 /s cryptdlg.dll
echo 完成百分之 90
sfc /purgecache
echo 完成百分之 100
cls
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 优化全部完成!
echo.
echo 感谢您使用winodws XP 优化处理文件!
echo.
echo By:【鹤冲天】
echo.
echo 如果好用就顶一下!!!!!^_^
echo.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo. & pause
exit
回复

使用道具 举报

92#
 楼主| 发表于 2007-2-4 01:56:33 | 只看该作者
在有这个
set ii=%ii:~0,1%

是什么意思?为什么我去掉它也没什么影响呢?(至少我没看到有什么影响)
回复

使用道具 举报

93#
发表于 2007-2-4 08:20:51 | 只看该作者
原帖由 鹤冲天 于 2007-2-4 01:56 AM 发表
在有这个

是什么意思?为什么我去掉它也没什么影响呢?(至少我没看到有什么影响)


它的意思是取你所输入的数值的第一位,当你输入1位数时看不到不同,可是当你输入17、25或360等的时候,就会知道它只取1、2或3了。
回复

使用道具 举报

94#
 楼主| 发表于 2007-2-4 10:17:48 | 只看该作者
哦,明白了!!谢谢,谢谢楼上!
回复

使用道具 举报

95#
 楼主| 发表于 2007-2-10 07:08:53 | 只看该作者
原帖由 namejm 于 2007-2-9 07:08 PM 发表
  也可以直接操作注册表,而无须生成临时文件

用reg add命令无法在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options下添加“项”啊!

  1. reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" /v 123654.dll
复制代码

这样可以在“Image File Execution Options”项下添加一个值!

  1. reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ASSTE.dll" /v 123654.dll
复制代码

这样也可以在它现成的子项中添加一个值!“ASSTE.dll”为系统自代的子项!
  1. reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\123654.dll" /v 123654.dll
复制代码

这样就不行!!“123654.dll”这个自己要建立个子项就不行!!提示成功但并没有写进去!
何解???
回复

使用道具 举报

96#
发表于 2007-2-10 10:50:29 | 只看该作者
  我这里没有出现这种情况呢,请看下面的图片。

CMD窗口情况.jpg (10.61 KB, 下载次数: 125)

CMD窗口情况.jpg

注册表情况.jpg (26.11 KB, 下载次数: 125)

注册表情况.jpg
回复

使用道具 举报

97#
发表于 2007-2-10 10:52:32 | 只看该作者





  1. reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\123654.dll\123654.dll”
复制代码

[ 本帖最后由 ccwan 于 2007-2-10 10:53 AM 编辑 ]
回复

使用道具 举报

98#
发表于 2007-2-10 11:04:40 | 只看该作者
谢谢分享
慢慢琢磨琢磨
回复

使用道具 举报

99#
 楼主| 发表于 2007-2-10 20:59:58 | 只看该作者
我这里也好了!
谢谢各位!!
帖子不另开是想回头把这帖子好好整理下!做个电子书方便!!
在有,我认为这样也方便刚刚接触批处理的朋友,有例子,有讲解,学习起来要方便一些!!
当然这是站在我这样批水平的人的角度去思考的!呵呵!:lol
开始学批处理的时候,我真的希望有类似这样的帖子的存在!偶的批水平的确有点:L!!
在这里再次感谢nemejm老师,ccwan 老师!6618斑竹等众多无优网友!!并提前预祝各位新年快乐!心想事成!!

[ 本帖最后由 鹤冲天 于 2007-2-10 09:08 PM 编辑 ]
回复

使用道具 举报

100#
 楼主| 发表于 2007-2-14 18:29:38 | 只看该作者
在看namejm老师前两天给的代码,

  1. SET Choice=
  2. 先设置选择为空吗??
  3. SET /P Choice=         请选择要进行的操作:  
  4. IF /I '%Choice:~0,1%'=='f' GOTO fix
  5. @rem ''和""有区别吗?::只有1个字符有效,选择=f跳转到fix
复制代码

我这网上找到的信息是
  1. if "参数" == "字符串"  待执行的命令
复制代码
用双引号啊!?
单双引号有区别吗?
回复

使用道具 举报

101#
发表于 2007-2-15 01:41:21 | 只看该作者
仔细研究一下.............
回复

使用道具 举报

102#
发表于 2007-3-5 23:06:43 | 只看该作者
很好的教程,感谢楼主!
回复

使用道具 举报

103#
发表于 2007-3-6 07:14:03 | 只看该作者
学习学习啊!!!!!!!!
回复

使用道具 举报

104#
发表于 2007-3-10 08:01:26 | 只看该作者
这个帖子..收藏.
回复

使用道具 举报

105#
发表于 2007-3-31 00:26:57 | 只看该作者
非常感谢:)
回复

使用道具 举报

106#
发表于 2009-4-29 23:27:31 | 只看该作者
下下来研究研究。。。。。。。。。
回复

使用道具 举报

107#
发表于 2011-5-25 17:27:07 | 只看该作者
不错,好贴,值得学习。
回复

使用道具 举报

108#
发表于 2011-6-14 17:56:00 | 只看该作者
很多细节的地方,很值得我们学习!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-4-25 08:34

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表