『楼 主』:
NT核系统服务管理批处理
欢迎大家访问我的 loveskoala.ys168.com
@echo off
color 1f
title NT核系统服务管理(适用平台:Windows 2000/XP/2003/vista)
cls
rem 汉化版权所有 (C) 2007 koala
rem 联系方法: [email]da2qia1ku5@126.com[/email]
setlocal
REM *** INIT_VARS ***
set CHK_SVC=YES
set XPSP2=FALSE
set SERVER=FALSE
set NT_SERVER_CHK=TRUE
echo ______________________________________________________________________________
echo.
echo koala友情提醒
echo.
echo 去处了繁余德语部分后,本人采用全局直译,部分意译的方法,运行过程中配合金山词
echo 霸,又结合了中国人的逻辑思维方式,对相关词语进行位置、适当的更换,完成此脚本汉化.
echo.
echo 此Germany(德国)的"NT核系统批处理优化脚本"由于代码过于庞大,因而运行过程中会
echo 出现局部Var(变量)无效的错误信息.但不要紧,试着多运行几次便可以了.
echo.
echo 完成此脚本的汉化、修正、调试、修改、美化 、"动大手术手术",花费了15个小时.由
echo 于本人能力有限,对VB编程(确切的说,应该是所有编程)一无所知,因而还得请热心的您来
echo 完成脚本中部分的VB脚本修正调试工作.
echo.
echo 人无完人,脚本难免还有不出错的地方,某些不得当之处还请不吝指点。
echo.
echo 让所有认识汉字的华人都能使用国外英文精品软件~!~!~!
echo.
echo 此脚本的官方发表日期 : 2005/12/18
echo /*** 为了保护汉化成果,我运用了一些技术手段对源代码进行
echo 了封装,如果对源代码感兴趣,就赶紧写信给我吧 ***/
echo E-mail:da2qia1ku5@126.com
echo ______________________________________________________________________________
set koala =
set /p koala= 请按"回车键"继续....
if "%koala%" == "" goto :START
:START
md "%USERPROFILE%\ntsvcfg"
copy /y psexec.exe %USERPROFILE%\ntsvcfg
path=%systemroot%\system32;%systemroot%;%systemdrive%\;%USERPROFILE%\ntsvcfg
set psexec=%USERPROFILE%\ntsvcfg\psexec.exe
set find=%SystemRoot%\System32\find.exe
set regedit=%SystemRoot%\regedit.exe
if not exist "%find%" goto :NOFIND
if not exist "%regedit%" goto :NOREGEDIT
if not exist "%psexec%" goto :NOPSEXEC
if not "%1" == "%*" goto :SYNTAX
if /I "%1"=="/?" goto :HELP
if /I "%1"=="/help" goto :HELP
if /I "%1"=="-h" goto :HELP
if /I "%1"=="--help" goto :HELP
if /I "%1"=="-?" goto :HELP
if /I "%1"=="--?" goto :HELP
if /I "%1"=="/fix" goto :FIX
cls
echo ***********************************************
echo * NT核系统服务管理 *
echo * 适用平台:Windows 2000/XP/2003/vista *
echo * 汉化版权所有(C)2007 koala(Koala Studio) *
echo ***********************************************
echo.
goto :VERSION
:SYNTAX
echo.
echo.
echo !!语法错误!!
echo ________________
echo.
echo 无效的参数.
goto :QUIT
:HELP
echo.
echo 参数:
echo /lan.......保持某些需要访问网络的服务状态不变!
echo /std.......关闭所有端口, 但某些服务的状态保持不变.
echo /all.......改变所有引发问题的系统服务.[不推荐此操作,强烈建议浏览[url]www.ntsvcfg.de[/url]]
echo /restore...撤消上次的更改.
echo /reLAN.....恢复需要访问网络的服务.
echo /default...恢复系统服务设置 (到第一次使用之前)
echo.
echo 例如: svc2kxp.cmd /all
echo.
set /P CHS= [按下 "G" 获取 GNU GPL 信息或者按下 "Q" 退出]?
echo.
if /I "%CHS%"=="G" goto :GNU_GPL
if /I "%CHS%"=="Q" goto :QUIT_EXT
CLS
goto :HELP
:GNU_GPL
CLS
echo 关于 GNU-General Public License授权给"svc2kxp.cmd"的信息
echo ===============================================================
echo.
echo 版权所有 (C) 2003-05 Ansgar Wiechers, Torsten Mann
echo 联系方法: [email]admin@ntsvcfg.de[/email]
echo.
echo 此程序为免费软件; 你可以重新分配它并可以在遵守由"免费软件基金会"发布的
echo "GUN 通用公共许可证"条款的前提条件下修改此程序 ;或者在遵守第二版的
echo 协议.你可以选择一个最新的版本.此程序的发布是希望它会产生应有的作用, 在没
echo 有"任何正当理由"; 以及内在保证的前提下不得用于任何形式的 "商业或适当的特
echo 别意图".请查看"GUN 通用公共许可证"获取详细信息.
rem
echo 随同此程序一起你应该已经收到一份"GUN 通用公共许可证";
echo 如果没有,请写信到:
echo.
echo Free Software Foundation, Inc.
echo 59 Temple Place, Suite 330
echo Boston, MA 02111-1307, USA.
echo.
set /P CHS= [按下 "H" 获取帮助 或者按 "Q" 退出]?
CLS
if /I "%CHS%"=="H" goto :HELP
if /I "%CHS%"=="Q" goto :QUIT_EXT
goto GNU_GPL
:VERSION
echo ==============================================================================
echo 正在检测系统版本 ...
echo.
if /I "%NT_SERVER_CHK%"=="FALSE" goto :SKIP_NT_SERVER_CHK
"%regedit%" /e "%TEMP%\~svr.txt" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions"
type "%TEMP%\~svr.txt"|"%find%" /i "Server" >NUL
if not errorlevel 1 set SERVER=TRUE
type "%TEMP%\~svr.txt"|"%find%" /i "LanMan" >NUL
if not errorlevel 1 set SERVER=TRUE
if exist "%TEMP%\~svr.txt" del /F /Q "%TEMP%\~svr.txt"
if /I "%SERVER%"=="TRUE" goto :NTSERVER
:SKIP_NT_SERVER_CHK
ver | "%find%" /i "Windows 2000" > nul
rem 如果返回错误信息不是假(1为假 0为真)
if not errorlevel 1 goto :OS2K
ver | "%find%" /i "Windows XP" > nul
if not errorlevel 1 goto :OSXP
ver | "%find%" /i "Microsoft Windows [Version 5.2.3790]" > nul
if not errorlevel 1 goto :OSXP64
echo !!出错!!
echo __________
echo.
echo 此脚本仅适用于 Windows 2000/XP 操作平台!
echo.
goto :QUIT
:NOFIND
echo.
echo !!出错!!
echo __________
echo.
echo 抱歉, 以下的文件已经丢失:
echo 请从其他电脑中自行拷贝一份到你的系统中.
echo.
echo # %SystemRoot%\System32\FIND.EXE
echo.
echo 请按下回车键 copy 到你的系统
pause >nul
copy /y regedit.exe "%systemroot%"
goto :START
:NOREGEDIT
echo.
echo !!出错!!
echo __________
echo.
echo 抱歉, 以下的文件已经丢失:
echo 请从其他电脑中自行拷贝一份到你的系统中.
echo.
echo # %SystemRoot%\REGEDIT.EXE
echo.
echo 请按下回车键 copy 到你的系统
pause >nul
copy /y find.exe "%systemroot%"
goto :START
:NOPSEXEC
echo.
echo !!出错!!
echo __________
echo.
echo 抱歉, 脚本需要以下的文件已经丢失:
echo.
echo # %USERPROFILE%\ntsvcfg\psexec.exe
echo.
echo 请按下回车键 copy 到你的系统
pause >nul
copy /y psexec.exe "%USERPROFILE%\ntsvcfg"
goto :START
:NTSERVER
echo.
echo !!出错!!
echo __________
echo.
echo 此脚本不支持 NT Server 版本!
echo.
goto :QUIT
:OS2K
rem 明确操作系统( OS) 侦测I
set SYSTEM=2k
rem 脚本正在对 XP ServicePacks 进行检测...
reg export "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion" "%TEMP%\~svclist.txt"
rem 下面的rem段是原来脚本中原形,虽然在系统SP检测的时间上没有什么改进(如果你的c:盘垃圾不经常清理,你可能会觉得用reg export快),但是减少生成临时文件的大小
rem 用下面脚本原形("%regedit%" /e) 产生的临时文件大小是优化(reg export)的9倍之多(本人计算机测试时候产生的文件大小分别为3585KB和395KB),不信试试。
rem "%regedit%" /e "%TEMP%\~svclist.txt" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 5" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 4" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 3" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 2" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 1" >NUL
if errorlevel==1 (
echo 您的操作系统是: Windows 2000 [未知类型 Service Pack或尚未安装]
goto NO_2KSP
)
echo 您的操作系统是: Windows 2000 [Service Pack 1]
goto :NO_2KSP
)
echo 您的操作系统是: Windows 2000 [Service Pack 2]
goto :NO_2KSP
)
echo 您的操作系统是: Windows 2000 [Service Pack 3]
goto :NO_2KSP
)
echo 您的操作系统是: Windows 2000 [Service Pack 4]
goto :NO_2KSP
)
echo 您的操作系统是: Windows 2000 [Service Pack 5]
goto :NO_2KSP
:NO_2kSP
if exist "%TEMP%\~svclist.txt" del /F /Q "%TEMP%\~svclist.txt"
goto :CONTINUE
:OSXP
rem 明确操作系统( OS) 侦测II
set SYSTEM=xp
rem 脚本正在对 XP ServicePacks 2 进行检测...
"%regedit%" /e "%TEMP%\~svclist.txt" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 4" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 3" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 2" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 1" >NUL
if errorlevel==1 (
SET XPSP2=FALSE
echo 您的操作系统是: Windows XP [未知类型 Service Pack或尚未安装]
goto :NO_XPSP
)
SET XPSP2=FALSE
echo 您的操作系统是: Windows XP [Service Pack 1]
goto :NO_XPSP
)
SET XPSP2=TRUE
echo 您的操作系统是: Windows XP [Service Pack 2]
goto :NO_XPSP
)
SET XPSP2=FALSE
echo 您的操作系统是: Windows XP [Service Pack 3]
goto :NO_XPSP
)
SET XPSP2=FALSE
echo 您的操作系统是: Windows XP [Service Pack 4]
goto :NO_XPSP
:OSXP64
rem 明确的操作系统发现 II
set SYSTEM=xp
rem 脚本正在对 XP ServicePacks 2 进行检测...
"%regedit%" /e "%TEMP%\~svclist.txt" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 2" >NUL
if errorlevel==1 (
type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 1" >NUL
if errorlevel==1 (
SET XPSP2=FALSE
echo !EXPERIMENTAL! Windows XP64 [未知类型 Service Pack或尚未安装]
goto NO_XPSP
)
SET XPSP2=FALSE
echo !EXPERIMENTAL! 您的操作系统是: Windows XP64 [Service Pack 1]
goto :NO_XPSP
)
SET XPSP2=TRUE
echo !EXPERIMENTAL! 您的操作系统是: Windows XP64 [Service Pack 2]
goto :NO_XPSP
:NO_XPSP
if exist "%TEMP%\~svclist.txt" del /F /Q "%TEMP%\~svclist.txt"
goto :CONTINUE
:CONTINUE
REM 如果需要,在 %userprofile% 创建"ntsvcfg"子目录
if not exist "%USERPROFILE%\ntsvcfg\*.*" md "%USERPROFILE%\ntsvcfg"
REM 从 ...\%USERNAME%\ntsvcfg 删除陈旧的脚本备份文件 :
if exist "%USERPROFILE%\dcom.reg" move /Y "%USERPROFILE%\dcom.reg" "%USERPROFILE%\ntsvcfg\dcom.reg"
if exist "%USERPROFILE%\dcomp.reg" move /Y "%USERPROFILE%\dcomp.reg" "%USERPROFILE%\ntsvcfg\dcomp.reg"
if exist "%USERPROFILE%\services.reg" move /Y "%USERPROFILE%\services.reg" "%USERPROFILE%\ntsvcfg\services.reg"
if exist "%USERPROFILE%\current_services_config.reg" move /Y "%USERPROFILE%\current_services_config.reg" "%USERPROFILE%\ntsvcfg"\current_services_config.reg
if exist "%USERPROFILE%\smb.reg" move /Y "%USERPROFILE%\smb.reg" "%USERPROFILE%\ntsvcfg\smb.reg"
if exist "%USERPROFILE%\FPRINT.REF" move /Y "%USERPROFILE%\FPRINT.REF" "%USERPROFILE%\ntsvcfg"\FPRINT.REF
if exist "%USERPROFILE%\handler_aim.reg" move /Y "%USERPROFILE%\handler_aim.reg" "%USERPROFILE%\ntsvcfg\handler_aim.reg"
if exist "%USERPROFILE%\handler_gopher.reg" move /Y "%USERPROFILE%\handler_gopher.reg" "%USERPROFILE%\ntsvcfg\handler_gopher.reg"
if exist "%USERPROFILE%\handler_telnet.reg" move /Y "%USERPROFILE%\handler_telnet.reg" "%USERPROFILE%\ntsvcfg\handler_telnet.reg"
if exist "%USERPROFILE%\services.reg.default" move /Y "%USERPROFILE%\services.reg.default" "%USERPROFILE%\ntsvcfg\services.reg.default"
if exist "%USERPROFILE%\dcom.reg.default" move /Y "%USERPROFILE%\dcom.reg.default" "%USERPROFILE%\ntsvcfg\dcom.reg.default"
if exist "%USERPROFILE%\dcomp.reg.default" move /Y "%USERPROFILE%\dcomp.reg.default" "%USERPROFILE%\ntsvcfg\dcomp.reg.default"
if exist "%USERPROFILE%\smb.reg.default" move /Y "%USERPROFILE%\smb.reg.default" "%USERPROFILE%\ntsvcfg\smb.reg.default"
if exist "%USERPROFILE%\handler_aim.reg.default" move /Y "%USERPROFILE%\handler_aim.reg.default" "%USERPROFILE%\ntsvcfg\handler_aim.reg.default"
if exist "%USERPROFILE%\handler_gopher.reg.default" move /Y "%USERPROFILE%\handler_gopher.reg.default" "%USERPROFILE%\ntsvcfg\handler_gopher.reg.default"
if exist "%USERPROFILE%\handler_telnet.reg.default" move /Y "%USERPROFILE%\handler_telnet.reg.default" "%USERPROFILE%\ntsvcfg\handler_telnet.reg.default"
REM *****变量声明*****
set SELECT="no"
set SVC_BAK=%USERPROFILE%\ntsvcfg\services.reg
set SVC_SAV=%USERPROFILE%\ntsvcfg\current_services_config.reg
set DCOM_BAK=%USERPROFILE%\ntsvcfg\dcom.reg
set DCOMP_BAK=%USERPROFILE%\ntsvcfg\dcomp.reg
set SMB_BAK=%USERPROFILE%\ntsvcfg\smb.reg
set DCOM_TMP=%TEMP%\dcomoff.reg
set DCOMP_TMP=%TEMP%\dcompoff.reg
set SMB_TMP=%TEMP%\smboff.reg
set FPRINT=%USERPROFILE%\ntsvcfg\FPRINT.REF
set HANDLER1=%USERPROFILE%\ntsvcfg\handler_aim.reg
set HANDLER2=%USERPROFILE%\ntsvcfg\handler_gopher.reg
set HANDLER3=%USERPROFILE%\ntsvcfg\handler_telnet.reg
set NB_TMP=%TEMP%\nb_off.vbs
set srctmp=%USERPROFILE%\ntsvcfg\~srcreate.vbs
set DHCP_CHANGES="YES"
REM *****选项*****
set SCHEDULER_ENABLED=NO
set UseXPSysRestore=YES
set RESTORE=NO
set SVC_MOD=NO
set USE_FPRINT=YES
set Deactivate_NetBIOS=YES
set RESTORE_MODE=2
REM *****应用程序路径******
set NET=%SystemRoot%\system32\net.exe
set SC=%SystemRoot%\system32\sc.exe
set FC=%SystemRoot%\system32\fc.exe
set IPCONFIG=%SystemRoot%\system32\ipconfig.exe
echo 正在审核当前用户的使用权限, 请稍等 ...
"%net%" user "%USERNAME%" 2> nul | "%find%" /i "admin" | "%find%" /i /v "name" > nul
if errorlevel 1 (
echo " " " : [主要群/域], 请稍等...
"%net%" user "%USERNAME%" /domain 2> nul | "%find%" /i "admin" | "%find%" /i /v "name" > nul
if errorlevel 1 (
echo.
echo 出错!
echo __________
echo 抱歉,你没有此进程要求的权限许可.请以管理员权限登陆.
echo.
echo.
echo 请按下回车键,以SYSTEM权限登陆系统(优化,原脚本不具备此功能)
pause>nul
"%psexec%" -d -i -s explorer
goto :END
)
)
set IMPORT_OLD_FILES=FALSE
rem 搜索 sc.exe
if not exist "%FPRINT%" echo 正在检查是否存在存在SC.EXE ...
"%sc%" qc > nul 2>&1
if errorlevel 1 (
echo !!出错!!
echo __________
echo 在系统目录下[%SystemRoot%\SYSTEM32\]未发现 SC.EXE.
echo 请从以下区域下载此文件:
echo.
echo.
echo -= [url]ftp://ftp.microsoft.com/reskit/win2000/sc.zip[/url] =-
echo.
echo 自行安装 SC.EXE
echo ======================
echo 如果存在活动的网络联接,svc2kxp.cmd 可能会自动尝试下载需求文件 sc.exe
goto :SC_DOWNLOAD
)
if /I "%1"=="/all" (
set SELECT="/all"
goto :SKIP_MENUE
)
if /I "%1"=="/relan" (
set SELECT="/relan"
goto :SKIP_MENUE
)
if /I "%1"=="/std" (
set SELECT="/std"
goto :SKIP_MENUE
)
if /I "%1"=="/default" goto :RESTORE_DEFAULTS
rem 检查已修改的服务
if /I %CHK_SVC%==YES (
if /I %USE_FPRINT%==YES (
if exist "%FPRINT%" (
rem 正在创建当前服务配置得快照...
if exist "%USERPROFILE%\ntsvcfg\svc2cmp.sav" del /F /Q "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
"%sc%" query type= service state= all bufsize= 8192 | %FIND% "SERVICE_NAME" >%TEMP%\~svclist.txt
for /F "tokens=1*" %%a in (%TEMP%\~svclist.txt) do (
echo %%b >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav"
"%sc%" query "%%b" | %FIND% "STATE" >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav"
"%sc%" qc "%%b" | %FIND% "DISPLAY_NAME" >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav"
"%SC%" qc "%%b" | %FIND% "START_TYPE" >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav"
echo. >> "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
)
del "%TEMP%\~svclist.txt"
"%FC%" "%FPRINT%" "%USERPROFILE%\ntsvcfg\svc2cmp.sav" >NUL
if errorlevel 1 goto :DIFF
goto OK
:DIFF
echo 正在检查已修改的服务 ...
echo 粗略评估:服务已经被修改过!
echo ==============================================================================
set SVC_MOD=YES
goto :MOD_END
:OK
echo 正在检查已修改的服务 ... OK
set SVC_MOD=NO
if exist "%USERPROFILE%\ntsvcfg\svc2cmp.sav" del /F /Q "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
goto :MOD_END
:MOD_END
REM
)
)
)
set CHK_SVC=NO
if /I "%1"=="/restore" goto :RESTORE
:MENUE
if /I "%1"=="/lan" goto :SKIP_MENUE
echo ______________________________________________________________________________
echo 程序控制台
echo.
echo (1) 网络: 保持某些需要访问网络的服务状态不变
echo (2) 标准: 关闭所有端口, 但某些服务的状态保持不变.
echo (3) 完全: 改变所有可能引发问题的系统服务.
echo (4) 恢复: 撤消上次更改.
echo (M) 选项: 获取其他更多选项
echo (Q) 退出: 离开程序界面
echo (E) 查看: 查看系统服务状态(系统当前服务配置与预期不符合时才可使用此项)
echo ______________________________________________________________________________
set /P CHS= 请选择您要进行的操作:
if /I "%CHS%"=="1" (
set SELECT="/lan"
goto :SKIP_MENUE
)
if /I "%CHS%"=="2" (
set SELECT="/std"
goto :SKIP_MENUE
)
if /I "%CHS%"=="3" (
set SELECT="/all"
goto :SKIP_MENUE
)
if /I "%CHS%"=="4" goto :RESTORE
if /I "%CHS%"=="R" goto :RESTORE
if /I "%CHS%"=="M" goto :MORE_OPTIONS
if /I "%SVC_MOD%"=="YES" if /I "%CHS%"=="E" goto :EVALUATE_SERVICES
if /I "%CHS%"=="G" goto :CREATING_NEW_FINGERPRINT
if /I "%CHS%"=="Q" goto :QUIT
cls
goto :START
:SKIP_MENUE
rem 检查是否存在陈旧的还原点.
rem if it is so old files will be restored before 在产生新更改之前,如果文件时间太久将会被恢复
if not exist "%SVC_BAK%" goto :NO_RESTORE
if /I %RESTORE_MODE%==3 goto :NO_RESTORE
if /I %RESTORE_MODE%==4 goto :NO_RESTORE
set RESTORE=YES
echo.
echo _______________________________________________________________________
echo.
echo [选择还原模式: %RESTORE_MODE%]
echo.
echo 注意: 发现陈旧的还原文件!
echo.
echo 这个程序已不是第一次运行了。为了使所做的更改生效,
echo 通常所有正确的陈旧还原点文件将会更新到一个新的的状态。
echo.
echo # 开始恢复 ...
goto RESTORE_EXT
:NO_RESTORE
rem 手动计划任务是否需要执行
if /I "%SYSTEM%"=="2k" goto :SKIP_SQUERY
if /I "%SYSTEM%"=="xp" (
if /I %SELECT%=="" goto :SKIP_SQUERY
if /I %SELECT%=="/all" goto :SKIP_SQUERY
if /I %XPSP2%==True (
set SCHEDULER_ENABLED=YES
goto :SKIP_SQUERY
)
)
echo.
echo.
echo 询问
echo ==================
echo.
echo 需要将"scheduler"服务设置为"已禁用"吗?
echo.
echo 如果你有定时计划任务[例如:杀毒软件的更新]那么你将不需要设置自动系统还原点,
echo 请"按任意键继续...立即"关闭[RPC]135端口和[计划任务]1025端口;否则请按"N"键.
echo ___________________________________________
echo.
set /P UNDO=计划任务已经失效- 关闭scheduler [y/n]?
if /I "%UNDO%"=="n" set SCHEDULER_ENABLED=YES
:SKIP_SQUERY
if not exist "%SVC_BAK%.default" (
echo.
echo 正在创建默认还原...
"%regedit%" /e "%SVC_BAK%.default" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
"%regedit%" /e "%DCOM_BAK%.default" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole
"%regedit%" /e "%DCOMP_BAK%.default" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc
"%regedit%" /e "%SMB_BAK%.default" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
"%regedit%" /e "%HANDLER1%.default" HKEY_CLASSES_ROOT\AIM
"%regedit%" /e "%HANDLER2%.default" HKEY_CLASSES_ROOT\gopher
"%regedit%" /e "%HANDLER3%.default" HKEY_CLASSES_ROOT\telnet
cls
echo ... 完成.
)
if exist "%SVC_BAK%" (
if /I %RESTORE_MODE%==2 goto :SKIP_SAVING
if /I %RESTORE_MODE%==4 goto :SKIP_SAVING
)
rem 保存注册表设置
echo _________________________________________________________________________
echo.
echo [选择还原模式: %RESTORE_MODE%]
echo.
echo 保存服务设置到
echo %SVC_BAK% ...
"%regedit%" /e "%SVC_BAK%" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
echo Saving DCOM settings to
echo %DCOM_BAK% ...
"%regedit%" /e "%DCOM_BAK%" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole
echo 保存 DCOM 标准协议 设置到
echo %DCOMP_BAK% ...
"%regedit%" /e "%DCOMP_BAK%" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc
echo 保存 SMB 设置到
echo %SMB_BAK%
"%regedit%" /e "%SMB_BAK%" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
echo 保存URL连接管理[AIM,gopher,telnet]设置到
echo %HANDLER1%
"%regedit%" /e "%HANDLER1%" HKEY_CLASSES_ROOT\AIM
echo %HANDLER2%
"%regedit%" /e "%HANDLER2%" HKEY_CLASSES_ROOT\gopher
echo %HANDLER3%
"%regedit%" /e "%HANDLER3%" HKEY_CLASSES_ROOT\telnet
echo.
echo 所有任务已完成.
echo ___________________________________________
echo.
:SKIP_SAVING
if /I "%SYSTEM%"=="xp" (
if /I %UseXPSysRestore%==YES (
goto :XPSYSRESTORE
)
)
:XPSYSRESTORE_DONE
rem 重新配置服务
rem 启动:手动
echo.
echo 设置"手动"类型服务....
echo ___________________________________________
echo.
echo # 正在检测 DHCP...
"%ipconfig%" -all | "%find%" /i "Lease" > nul
if errorlevel 1 (
rem 尝试其他方法启动 DHCP
"%ipconfig%" -all | "%find%" /i "DHCP-Server" > nul
if errorlevel 1 (
echo ... 未发现活动的 DHCP.
echo.
echo 注意
echo ======
echo 你的配置预示着 DHCP 服务将不再需要使用.
echo 但是如果你使用 XDSL 尝试联接到网络时可能会产生错误.
echo 如果你在联接到网络期间遇到此故障,请重新将DHCP服务
echo 激活为"手动".
echo.
echo ___________________________________________
echo.
"%sc%" config DHCP start= demand
goto :SKIP_DHCP
)
)
set DHCP_CHANGES="NO"
echo ... DHCP 激活, 服务状态将不会再改变!
echo.
:SKIP_DHCP
"%sc%" config dmadmin start= demand
"%sc%" config DNSCache start= demand
"%sc%" config mnmsrvc start= demand
"%sc%" config MSIServer start= demand
"%sc%" config NetDDE start= demand
"%sc%" config NetDDEdsdm start= demand
"%sc%" config Netman start= demand
"%sc%" config NTLMSsp start= demand
"%sc%" config NtmsSvc start= demand
"%sc%" config PolicyAgent start= demand
"%sc%" config RASAuto start= demand
"%sc%" config RASMan start= demand
"%sc%" config RSVP start= demand
"%sc%" config Scardsvr start= demand
"%sc%" query ScardDrv | "%find%" /i "OpenService FAILED" >NUL
if errorlevel 1 "%sc%" config ScardDrv start= demand
if /I %XPSP2%==True (
rem 如果 XP SP2已安装那么XP-ICF的更改将会减少
if /I %SELECT%=="/std" goto :SKIP_FIREWALL
)
"%sc%" config SharedAccess start= demand
:SKIP_FIREWALL
"%sc%" config Sysmonlog start= demand
"%sc%" config TAPISrv start= demand
"%sc%" config TrkWks start= demand
"%sc%" config UPS start= demand
"%sc%" config W32Time start= demand
"%sc%" config WMI start= demand
if /I %SELECT%=="/all" (
"%sc%" config SamSs start= demand
"%sc%" config LmHosts start= demand
"%sc%" config Winmgmt start= demand
)
if /I "%SYSTEM%"=="2k" (
"%sc%" config AppMgmt start= demand
"%sc%" config Browser start= demand
"%sc%" config clipsrv start= demand
"%sc%" config EventSystem start= demand
"%sc%" config Fax start= demand
"%sc%" config netlogon start= demand
"%sc%" config RPCLocator start= demand
"%sc%" config Utilman start= demand
if /I %SELECT%=="/all" (
"%sc%" config seclogon start= demand
"%sc%" config RPCSs start= demand
"%sc%" config lanmanServer start= demand
)
)
if /I "%SYSTEM%"=="xp" (
"%sc%" config ALG start= demand
"%sc%" config FastUserSwitchingCompatibility start= demand
"%sc%" config helpsvc start= demand
"%sc%" config ImapiService start= demand
"%sc%" config Nla start= demand
"%sc%" config RdSessMgr start= demand
"%sc%" config seclogon start= demand
"%sc%" config stisvc start= demand
"%sc%" config SwPrv start= demand
"%sc%" config TermService start= demand
"%sc%" config upnphost start= demand
"%sc%" config VSS start= demand
"%sc%" query WmdmPmSp | "%find%" /i "OpenService FAILED" >NUL
if errorlevel 1 "%sc%" config WmdmPmSp start= demand
"%sc%" config WmiApSrv start= demand
rem Wireless Zero Configuration - fuer WLAN-Verbindungen notwendig.
rem Falls erforderlich auf AUTO stellen.
rem "%sc%" config WZCSVC start= demand
)
echo.
rem 启动:自动
echo 设置"自动"类型服务...
"%sc%" config dmserver start= auto
"%sc%" config eventlog start= auto
"%sc%" config PlugPlay start= auto
"%sc%" config ProtectedStorage start= auto
"%sc%" config sens start= auto
"%sc%" config spooler start= auto
if /I "%SYSTEM%"=="2k" (
"%sc%" config lanmanworkstation start= auto
"%sc%" config alerter start= auto
)
if /I "%SYSTEM%"=="xp" (
"%sc%" query InteractiveLogon | "%find%" /i "OpenService FAILED" >NUL
if errorlevel 1 "%sc%" config InteractiveLogon start= auto
"%sc%" config Audiosrv start= auto
"%sc%" config CryptSvc start= auto
"%sc%" config RPCSs start= auto
"%sc%" config ShellHWDetection start= auto
"%sc%" config srservice start= auto
"%sc%" query uploadmgr | "%find%" /i "OpenService FAILED" >NUL
if errorlevel 1 "%sc%" config uploadmgr start= auto
"%sc%" config WebClient start= auto
)
echo.
rem 启动:已禁用
echo 设置"已禁用"类型服务....
"%sc%" config cisvc start= disabled
"%sc%" config MSDTC start= disabled
"%sc%" config RemoteAccess start= disabled
"%sc%" config TlntSvr start= disabled
"%sc%" config messenger start= disabled
if /I %SELECT%=="/all" (
"%sc%" query BITS | "%find%" /i "SERVICE_NAME" >NUL
if not errorlevel 1 "%sc%" config BITS start= disabled
"%sc%" query wuauserv | "%find%" /i "SERVICE_NAME" >NUL
if not errorlevel 1 "%sc%" config wuauserv start= disabled
"%sc%" config schedule start= disabled
"%sc%" config RemoteRegistry start= disabled
)
if /I "%SYSTEM%"=="xp" (
"%sc%" config ERSvc start= disabled
"%sc%" config HidServ start= disabled
"%sc%" config SSDPSRV start= disabled
if /I %SELECT%=="/lan" (
if /I %SCHEDULER_ENABLED%==NO "%sc%" config schedule start= disabled
)
if /I %SELECT%=="/std" (
if /I %SCHEDULER_ENABLED%==NO "%sc%" config schedule start= disabled
)
if /I %XPSP2%==True (
echo.
echo 停用 Windows XP SP2 的安全中心...
"%sc%" config wscsvc start= disabled
)
)
echo.
echo ------------------
echo #检查并将不需要的系统服务停止...
echo.
"%sc%" query cisvc | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop cisvc
"%sc%" query RemoteAccess | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop RemoteAccess
"%sc%" query TlntSvr | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop TlntSvr
"%sc%" query MSDTC | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop MSDTC
"%sc%" query messenger | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop messenger
if /I %SELECT%=="/all" (
"%sc%" query BITS | "%find%" /i "SERVICE_NAME" >NUL
if not errorlevel 1 (
"%sc%" query BITS | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop BITS
)
"%sc%" query wuauserv | "%find%" /i "SERVICE_NAME" >NUL
if not errorlevel 1 (
"%sc%" query wuauserv | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop wuauserv
)
"%sc%" query schedule | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop schedule
)
if /I "%SYSTEM%"=="xp" (
if /I %SELECT%=="/lan" (
if /I %SCHEDULER_ENABLED%==NO "%net%" (
"%sc%" query schedule | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop schedule
)
)
if /I %SELECT%=="/std" (
if /I %SCHEDULER_ENABLED%==NO "%net%" (
"%sc%" query schedule | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop schedule
)
if /I %XPSP2%==True (
"%sc%" query wscsvc | "%find%" /i "4 RUNNING" >NUL
if not errorlevel 1 "%net%" stop wscsvc
)
)
echo ------------------
echo 关闭 DCOM 服务...
echo REGEDIT4 > "%DCOM_TMP%"
echo. >> "%DCOM_TMP%"
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole] >> "%DCOM_TMP%"
echo "EnableDCOM"="N" >> "%DCOM_TMP%"
echo "EnableDCOMHTTP"="N" >> "%DCOM_TMP%"
echo. >> "%DCOM_TMP%"
echo. >> "%DCOM_TMP%"
"%regedit%" /s "%DCOM_TMP%"
del /F /Q "%DCOM_TMP%"
echo 关闭DCOM 标准端口 ...
echo REGEDIT4 > "%DCOMP_TMP%"
echo. >> "%DCOMP_TMP%"
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc] >> "%DCOMP_TMP%"
echo "DCOM Protocols"=hex(7):00,00,00,00 >> "%DCOMP_TMP%"
echo. >> "%DCOMP_TMP%"
echo. >> "%DCOMP_TMP%"
"%regedit%" /s "%DCOMP_TMP%"
del /F /Q "%DCOMP_TMP%"
echo 关闭135端口(可能包括1025,或者更多) ...
echo - 封闭RPC客户端端口
echo REGEDIT4 > "%SMB_TMP%"
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ClientProtocols] >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
if /I %SCHEDULER_ENABLED%==NO (
echo - 高级RPC配置
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet] >> "%SMB_TMP%"
echo "PortsInternetAvailable"="N" >> "%SMB_TMP%"
echo "UseInternetPorts"="N" >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
)
if /I %XPSP2%==TRUE (
echo - 高级RPC配置
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet] >> "%SMB_TMP%"
echo "PortsInternetAvailable"="N" >> "%SMB_TMP%"
echo "UseInternetPorts"="N" >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
)
echo - 去除不需要的URL连接管理[AIM,gopher,telnet]
echo [-HKEY_CLASSES_ROOT\AIM] >> "%SMB_TMP%"
echo [-HKEY_CLASSES_ROOT\gopher] >> "%SMB_TMP%"
echo [-HKEY_CLASSES_ROOT\telnet] >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
"%regedit%" /s "%SMB_TMP%"
del /F /Q "%SMB_TMP%"
if /I %SELECT%=="/all" (
echo.
echo 关闭SMB的端口445...
echo REGEDIT4 > "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters] >> "%SMB_TMP%"
echo "SMBDeviceEnabled"=dword:00000000 >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
"%regedit%" /s "%SMB_TMP%"
del /F /Q "%SMB_TMP%"
set REBOOT_REQUIRED=yes
)
if /I %SELECT%=="/std" (
echo.
echo 关闭SMB的端口445...
echo REGEDIT4 > "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters] >> "%SMB_TMP%"
echo "SMBDeviceEnabled"=dword:00000000 >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
"%regedit%" /s "%SMB_TMP%"
del /F /Q "%SMB_TMP%"
set REBOOT_REQUIRED=yes
)
if /I %SELECT%=="/std" goto :NB_DISABLE
if /I %SELECT%=="/all" goto :NB_DISABLE
goto :SKIP_NB_DISABLE
:NB_DISABLE
if /I %DEACTIVATE_NETBIOS%==NO (
echo.
echo 由于SP2"的网络基本输入输出系统【Netbios】"出现问题,
echo 所以此选项将会跳过.
echo.
goto :SKIP_NB_DISABLE
)
rem (因为 SP2 的网络基本输入输出系统【Netbios】出现问题)
if /I %XPSP2%==True (
echo.
echo 注意:
echo -----
echo 如果你对Windows XP Service Pack 2进行
echo 更新后出现问题请按照以下方法来做:
echo.
echo set Deactivate_NetBIOS=NO
echo.
)
rem *** Thx2 Johannes Lichtenberger for the following lines using VBScript***
rem 约翰尼斯 李顿勃.Thx2关闭用以下的VBScript
echo 关闭当前所有的NetBios接口...
echo.
echo On Error Resume Next>>"%nb_tmp%"
echo.>>"%nb_tmp%"
echo TcpipoverNetbios = 2 '0=NetbiosfromDHCP 1=EnableNetbios 2=DisableNetbios>>"%nb_tmp%"
echo.>> "%nb_tmp%"
echo strComputer = ".">>"%nb_tmp%"
echo Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")>>"%nb_tmp%"
echo Set objNICs = objWMIService.ExecQuery _>>"%nb_tmp%"
echo ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")>>"%nb_tmp%"
echo For Each objNic In objNICs>>"%nb_tmp%"
echo errTcpipNetbios = objNic.SetTCPIPNetBIOS(TcpipoverNetbios)>>"%nb_tmp%"
echo Next>>"%nb_tmp%"
"%SYSTEMROOT%\SYSTEM32\CSCRIPT.EXE" "%nb_tmp%"
del /F /Q "%nb_tmp%"
set REBOOT_REQUIRED=yes
:SKIP_NB_DISABLE
rem 跳过 Billboard 因为 /all 参数已经使用
if /I %SELECT%=="/all" goto :SW_ALL
if /I %SELECT%=="/std" goto :SW_ALL
if /I %SELECT%=="/relan" goto :SW_ALL
echo.
echo ___________________________________________________________________
echo.
echo *** 程序运行反馈情况***
echo.
echo 并不是所有的更改都能显示出来的.为了更正在[url]www.ntsvcfg.de[/url]
echo 列出所有问题,请使用参数 '/all'或者选择第 "3" 项!
if /I %DHCP_CHANGES%=="YES" (
echo.
echo DHCP重要注意事项
echo =====================
echo 你的配置预示着 DHCP 服务将不再需要使用. 但是如果你使用
echo XDSL尝试联接到网络时可能会产生错误. 如果你在联接到网络
echo 期间遇到此故障,请重新将DHCP服务激活为"手动".
echo.
)
echo ___________________________________________________________________
:SW_ALL
if /I %SELECT%=="/relan" (
rem 启动:自动
echo.
echo ------------------
echo 正在启动服务...
"%sc%" config LmHosts start= auto
"%sc%" config RemoteRegistry start= auto
"%sc%" config SamSs start= auto
"%sc%" config Winmgmt start= auto
if /I "%SYSTEM%"=="2k" (
"%sc%" config RPCSs start= auto
"%sc%" config lanmanServer start= auto
"%sc%" config seclogon start= auto
)
if /I "%SYSTEM%"=="XP" (
rem 配置"%sc%"共享入口为启动类型自动
)
rem 重新启动服务(start re-enabled services)
echo.
echo ------------------
echo 重新启动服务[Re]...
echo.
"%sc%" query RemoteRegistry | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start RemoteRegistry
"%sc%" query SamSs | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start SamSs
"%sc%" query LmHosts | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start LmHosts
"%sc%" query Winmgmt | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start Winmgmt
if /I "%SYSTEM%"=="2k" (
"%sc%" query LanmanServer | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start lanmanServer
"%sc%" query RPCSs | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start RPCSs
"%sc%" query Seclogon | "%find%" /i "1 STOPPED" >NUL
if not errorlevel 1 "%net%" start seclogon
)
if /I "%SYSTEM%"=="XP" (
rem 启动"%net%"共享入口
)
rem 打开SMB 445端口
echo.
echo ------------------
echo 打开SMB 445 端口...
echo REGEDIT4 > "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters] >> "%SMB_TMP%"
echo "SMBDeviceEnabled"=dword:00000001 >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
echo. >> "%SMB_TMP%"
"%regedit%" /s "%SMB_TMP%"
del /F /Q "%SMB_TMP%"
set REBOOT_REQUIRED=yes
)
rem 创建当前系统服务配置的快照..
if exist "%FPRINT%" del /F /Q "%FPRINT%"
if /I %USE_FPRINT%==YES (
echo.
echo 创建快照将会占用一些时间......
"%sc%" query type= service state= all bufsize= 8192 | %FIND% "SERVICE_NAME" > %TEMP%\~svclist.txt
for /F "tokens=1*" %%a in (%TEMP%\~svclist.txt) do (
echo %%b >>"%FPRINT%"
"%sc%" query "%%b" | %FIND% "STATE" >>"%FPRINT%"
"%sc%" qc "%%b" | %FIND% "DISPLAY_NAME" >>"%FPRINT%"
"%SC%" qc "%%b" | %FIND% "START_TYPE" >>"%FPRINT%"
echo. >> "%FPRINT%"
)
del "%TEMP%\~svclist.txt"
echo ...完成.
)
goto :END
:RESTORE
echo ____________________________________________________
echo.
set /P UNDO= 撤销上次的更改 [是/否(y/n)]?
if /I "%UNDO%"=="y" (
echo _______________________________________________________________
echo.
echo Hinweis:
echo ========
echo 系统在导出备份时也许可能会报错.你只需点击"是"即可忽略它!
echo _______________________________________________________________
echo 状况:
echo -------
:RESTORE_EXT
if exist "%SVC_BAK%" (
echo 正在导入服务...
echo ["%SVC_BAK%"]
"%regedit%" /s "%SVC_BAK%"
set action=""
)
if exist "%DCOM_BAK%" (
echo 正在导入DCOM ...
echo ["%DCOM_BAK%"]
"%regedit%" /s "%DCOM_BAK%"
)
if exist "%DCOMP_BAK%" (
echo 正在导入DCOM-standard protocols ...
echo ["%DCOMP_BAK%"]
"%regedit%" /s "%DCOMP_BAK%"
)
if exist "%SMB_BAK%" (
echo 正在导入 SMB-设置...
echo ["%SMB_BAK%"]
echo - 正在删除激活的SMB设备注册表键 ...
echo REGEDIT4 > "%USERPROFILE%\smbpatch~.reg"
echo. >> "%USERPROFILE%\smbpatch~.reg"
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters] >> "%USERPROFILE%\smbpatch~.reg"
echo "SMBDeviceEnabled"=- >> "%USERPROFILE%\smbpatch~.reg"
echo. >> "%USERPROFILE%\smbpatch~.reg"
echo. >> "%USERPROFILE%\smbpatch~.reg"
"%SystemRoot%\regedit.exe" /s "%USERPROFILE%\smbpatch~.reg"
del /F /Q "%USERPROFILE%\smbpatch~.reg"
"%regedit%" /s "%SMB_BAK%"
)
if exist "%HANDLER1%" (
echo 正在导入 URL_HANDLER AIM ...
echo ["%HANDLER1%"]
"%regedit%" /s "%HANDLER1%"
)
if exist "%HANDLER2%" (
echo 正在导入 URL_HANDLER GOPHER ...
echo ["%HANDLER2%"]
"%regedit%" /s "%HANDLER2%"
)
if exist "%HANDLER3%" (
echo 正在导入 URL_HANDLER TELNET ...
echo ["%HANDLER3%"]
"%regedit%" /s "%HANDLER3%"
)
rem Skipping back to next state
if /I "%RESTORE%"=="YES" goto :NO_RESTORE
echo 正在删除 RPC Internet 注册表键 ....
echo REGEDIT4 >"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet] >>"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
"%regedit%" /s "%USERPROFILE%\svc_fix.reg"
del /F /Q "%USERPROFILE%\svc_fix.reg"
rem 创建当前服务配置的快照...
if exist "%FPRINT%" del /F /Q "%FPRINT%"
if /I %USE_FPRINT%==YES (
echo.
echo 创建快照将会占用一些时间...
"%sc%" query type= service state= all bufsize= 8192 | %FIND% "SERVICE_NAME" > %TEMP%\~svclist.txt
for /F "tokens=1*" %%a in (%TEMP%\~svclist.txt) do (
echo %%b >>"%FPRINT%"
"%sc%" query "%%b" | %FIND% "STATE" >>"%FPRINT%"
"%sc%" qc "%%b" | %FIND% "DISPLAY_NAME" >>"%FPRINT%"
"%SC%" qc "%%b" | %FIND% "START_TYPE" >>"%FPRINT%"
echo. >> "%FPRINT%"
)
del "%TEMP%\~svclist.txt"
echo ...完成.
)
echo.
echo _______________________________________________________________
echo.
echo *** 程序运行反馈情况 ***
echo.
echo. 如果你未在状态框上看到任何信息,说明没有备份的文件可以用来进行恢复,
echo 恢复完成.请重新激活NetBios分配给每个你想使用的NIC,然后重启。
echo ________________________________________________________________
)
goto :END
:RESTORE_DEFAULTS
echo.
echo *** 恢复车间设置 ***
echo.
echo ______________________________________________________________________________
echo.
set /P UNDO= 恢复到(在使用脚本之前, NetBIOS除外) 默认状态[y/n]?
if /I "%UNDO%"=="y" (
echo.
echo - 恢复最初的服务配置[如果备份文件存在] ...
if exist "%SVC_BAK%.default" (
echo "%SVC_BAK%.default"
"%regedit%" /s "%SVC_BAK%.default"
)
if exist "%DCOM_BAK%.default" (
echo "%DCOM_BAK%.default"
"%regedit%" /s "%DCOM_BAK%.default"
)
if exist "%DCOMP_BAK%.default" (
echo "%DCOMP_BAK%.default"
"%regedit%" /s "%DCOMP_BAK%.default"
)
if exist "%SMB_BAK%.default" (
echo "%SMB_BAK%.default"
echo - 正在删除激活的SMB设备注册表键 ...
echo REGEDIT4 > "%USERPROFILE%\smbpatch~.reg"
echo. >> "%USERPROFILE%\smbpatch~.reg"
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters] >> "%USERPROFILE%\smbpatch~.reg"
echo "SMBDeviceEnabled"=- >> "%USERPROFILE%\smbpatch~.reg"
echo. >> "%USERPROFILE%\smbpatch~.reg"
echo. >> "%USERPROFILE%\smbpatch~.reg"
"%SystemRoot%\regedit.exe" /s "%USERPROFILE%\smbpatch~.reg"
del /F /Q "%USERPROFILE%\smbpatch~.reg"
"%regedit%" /s "%SMB_BAK%.default"
)
if exist "%HANDLER1%.default" (
echo "%HANDLER1%.default"
"%regedit%" /s "%HANDLER1%.default"
)
if exist "%HANDLER2%.default" (
echo "%HANDLER2%.default"
"%regedit%" /s "%HANDLER2%.default"
)
if exist "%HANDLER3%.default" (
echo "%HANDLER3%.default"
"%regedit%" /s "%HANDLER3%.default"
)
echo ... 完成.
echo - 正在删除 RPC Internet 注册表键 ...
echo REGEDIT4 >"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet] >>"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
"%regedit%" /s "%USERPROFILE%\svc_fix.reg"
del /F /Q "%USERPROFILE%\svc_fix.reg"
echo ... 完成.
)
goto :QUIT
:SC_DOWNLOAD
echo ______________________________________________________________
echo.
echo 你当前的状态是否已经连接到internet?
echo.
set /P UNDO= 请选择: [y/n]?
if /I "%UNDO%"=="y" goto :SC_DOWNLOAD_OK
goto :END
:SC_DOWNLOAD_OK
if exist "%SYSTEMROOT%\sc.zip" goto :SCE
echo 正在生成 FTP 脚本 ...
if exist "%USERPROFILE%"\script_sc.ls del /F "%USERPROFILE%\script_sc.ls"
echo open 207.46.133.140 >"%USERPROFILE%\script_sc.ls"
echo user anonymous [email]anonymous@aol.com[/email] >>"%USERPROFILE%\script_sc.ls"
echo type binary >>"%USERPROFILE%\script_sc.ls"
echo user anonymous [email]anonymous@aol.com[/email] >>"%USERPROFILE%\script_sc.ls"
echo type binary >>"%USERPROFILE%\script_sc.ls"
echo get /reskit/win2000/sc.zip "%SYSTEMROOT%\System32\SC.ZIP" >>"%USERPROFILE%\script_sc.ls"
echo quit >>"%USERPROFILE%\script_sc.ls"
echo 正在下载 SC.EXE ...
ftp -s:"%USERPROFILE%\script_sc.ls"
del /F "%USERPROFILE%\script_sc.ls"
:SCE
if exist "%SYSTEMROOT%\System32\pkunzip.exe" goto :PKE
echo 正在生成 FTP 脚本 ...
if exist "%USERPROFILE%"\script_pk.ls del /F "%USERPROFILE%\script_pk.ls"
echo open ftp.uni-duesseldorf.de >"%USERPROFILE%\script_pk.ls"
echo user anonymous [email]anonymous@aol.com[/email] >>"%USERPROFILE%\script_pk.ls"
echo type binary >>"%USERPROFILE%\script_pk.ls"
echo user anonymous [email]anonymous@aol.com[/email] >>"%USERPROFILE%\script_pk.ls"
echo type binary >>"%USERPROFILE%\script_pk.ls"
echo get /pub/ie/pkunzip.exe "%SYSTEMROOT%\System32\pkunzip.exe" >>"%USERPROFILE%\script_pk.ls"
echo quit >>"%USERPROFILE%\script_pk.ls"
echo 正在下载 PKUNZIP.EXE ...
ftp -s:"%USERPROFILE%\script_pk.ls"
del /F "%USERPROFILE%\script_pk.ls"
:PKE
if not exist "%SYSTEMROOT%\System32\sc.zip" (
echo.
echo.
echo 下载 SC.ZIP 文件失败. 请手动下载并将它复制到%SYSTEMROOT%\目录.
)
if not exist "%SYSTEMROOT%\System32\pkunzip.exe" (
echo.
echo 未发现文件PKUNZIP.EXE. 请从压缩包中解压 SC.EXE.
)
if exist "%SYSTEMROOT%\System32\SC.ZIP" (
if exist "%SYSTEMROOT%\System32\pkunzip.exe" (
"%SYSTEMROOT%\System32\pkunzip.exe" -e "%SYSTEMROOT%\System32\sc.zip" sc.exe
)
)
move /Y sc.exe "%SYSTEMROOT%\System32\"
echo.
echo 正在重新启动脚本 ...
goto :START
:FIX
echo.
echo -= svc2kxp.cmd 计划任务修复 =-
echo.
echo.
echo 如果你想修复疑问:" 在Windows XP启动后不自动执行计划任务
echo 在运行 v2.0 - v2.1build0版本的脚本",按下"Y"键.
echo.
set /P UNDO= 修复问题 [y/n]?
if /I "%UNDO%"=="y" (
echo REGEDIT4 >"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet] >>"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
echo. >>"%USERPROFILE%\svc_fix.reg"
"%regedit%" /s "%USERPROFILE%\svc_fix.reg"
del /F /Q "%USERPROFILE%\svc_fix.reg"
echo ______________________________________
echo.
echo 完成. 请重新启动并再次检查开放的端口 ...!
)
rem 创建当前服务设置的快照..
if exist "%FPRINT%" del /F /Q "%FPRINT%"
goto quit
if /I %USE_FPRINT%==YES (
echo.
echo Creating fingerprint which will take a few seconds ...
"%sc%" query type= service state= all bufsize= 8192 | %FIND% "SERVICE_NAME" > %TEMP%\~svclist.txt
for /F "tokens=1*" %%a in (%TEMP%\~svclist.txt) do (
echo %%b >>"%FPRINT%"
"%sc%" query "%%b" | %FIND% "STATE" >>"%FPRINT%"
"%sc%" qc "%%b" | %FIND% "DISPLAY_NAME" >>"%FPRINT%"
"%SC%" qc "%%b" | %FIND% "START_TYPE" >>"%FPRINT%"
echo. >> "%FPRINT%"
)
del "%TEMP%\~svclist.txt"
echo ... 完成.
)
goto :QUIT
rem **** 添加特殊目录(Additional Feature List)****
:MORE_OPTIONS
cls
echo ______________________________________________________________________________
echo.
echo *** 其他选项 ***
echo =====================================
echo.
if /I "%SVC_MOD%"=="YES" (
echo [E]...显示一个自从上次使用 svc2kxp.cmd 修改服务的目录
echo.
)
echo [G]...为系统服务创建一个快照,用来发现并纠正系统服务的更改情况
echo.
echo [S]...保存当前 NT 服务的配置情况(自动/手动/已禁用).
echo.
echo [B]...返回主程序.
echo.
echo [Q]...退出.
echo.
echo ______________________________________________________________________________
echo.
if /I "%SVC_MOD%"=="NO" set /P CHS= 请选择您要进行的操作:
if /I "%SVC_MOD%"=="YES" set /P CHS= 请选择您要进行的操作:
if /I "%SVC_MOD%"=="YES" if /I "%CHS%"=="E" GOTO :EVALUATE_SERVICES
if /I "%CHS%"=="G" GOTO :CREATING_NEW_FINGERPRINT
if /I "%CHS%"=="B" (
CLS
GOTO :MENUE
)
if /I "%CHS%"=="S" GOTO :SAVE_SVC_SETTINGS
if /I "%CHS%"=="Q" GOTO :QUIT
GOTO :MORE_OPTIONS
:EVALUATE_SERVICES
cls
echo ______________________________________________________________________________
echo.
echo *** 系统服务评估情况 ***
echo.
"%FC%" /N "%FPRINT%" "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
echo [B]...返回.
echo [U]...更新.
echo [Q]...退出.
echo ______________________________________________________________________________
echo.
set /P CHS= 请选择您要进行的操作:
if /I "%CHS%"=="B" GOTO :MORE_OPTIONS
if /I "%CHS%"=="U" GOTO :CREATING_NEW_FINGERPRINT
if /I "%CHS%"=="Q" GOTO :QUIT
GOTO :MORE_OPTIONS
:SAVE_SVC_SETTINGS
cls
echo ______________________________________________________________________________
echo.
echo *** 管理当前服务配置菜单选项 ***
echo --------------------------------------------
echo.
set /P CHS= 您是否需要保存当前的服务设置[y/n]?
if /I "%CHS%"=="N" GOTO :MORE_OPTIONS
if /I "%CHS%"=="Y" (
echo 保存当前服务的设置状态到:
echo.
echo - %SVC_SAV%
"%regedit%" /e "%SVC_SAV%" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
echo.
echo ... 完成!
echo ______________________________________________________________________________
echo.
echo 敲击任意键返回.
pause>NUL
)
if /I "%CHS%"=="Q" GOTO :QUIT
goto :MORE_OPTIONS
pause >NUL
goto :MORE_OPTIONS
:CREATING_NEW_FINGERPRINT
cls
echo ______________________________________________________________________________
echo.
echo *** 创建新的指纹快照 ***
echo ------------------------------
echo.
set /P CHS= 是否创建新的指纹快照 [Y/N]?
if /I "%CHS%"=="Y" (
if exist "%FPRINT%" del /F /Q "%FPRINT%"
echo 创建新的指纹快照将会占用一些时间,请稍等 ...
"%sc%" query type= service state= all bufsize= 8192 | %FIND% "SERVICE_NAME" > %TEMP%\~svclist.txt
for /F "tokens=1*" %%a in (%TEMP%\~svclist.txt) do (
echo %%b >>"%FPRINT%"
"%sc%" query "%%b" | %FIND% "STATE" >>"%FPRINT%"
"%sc%" qc "%%b" | %FIND% "DISPLAY_NAME" >>"%FPRINT%"
"%SC%" qc "%%b" | %FIND% "START_TYPE" >>"%FPRINT%"
echo. >> "%FPRINT%"
)
del "%TEMP%\~svclist.txt"
echo ... 完成.
echo ______________________________________________________________________________
echo.
echo [按任意键继续...]
set CHK_SVC=YES
PAUSE >NUL
)
cls
GOTO :MORE_OPTIONS
:XPSYSRESTORE
REM 创建一个系统还原点// 源代码: MS Technet Scriptcenter
echo.
echo 如果 Windows XP 的系统还原可用,创建系统还原点 ...
if exist "%srctmp%" del /F /Q "%srctmp%"
echo CONST DEVICE_DRIVER_INSTALL = 10 >"%srctmp%"
echo CONST BEGIN_SYSTEM_CHANGE = 100 >>"%srctmp%"
echo.>>"%srctmp%"
echo strComputer = ".">>"%srctmp%"
echo Set objWMIService = GetObject("winmgmts:" _ >>"%srctmp%"
echo ^& "{impersonationLevel=impersonate}!\\" ^& strComputer ^& "\root\default")>>"%srctmp%"
echo.>>"%srctmp%"
echo Set objItem = objWMIService.Get("SystemRestore")>>"%srctmp%"
echo errResults = objItem.CreateRestorePoint _ >>"%srctmp%"
echo ("svc2kxp.cmd 创建的还原点", DEVICE_DRIVER_INSTALL, BEGIN_SYSTEM_CHANGE)>>"%srctmp%"
call "%srctmp%"
del /F /Q "%srctmp%"
echo.
goto :XPSYSRESTORE_DONE
:END
if "%REBOOT_REQUIRED%"=="yes" (
echo.
echo ______________________________________________________
echo.
echo *** 程序运行反馈情况 ***
echo.
echo.
if /I %SELECT%=="/all" echo 所有更改已经成功应用.
if /I %SELECT%=="/std" echo 某些系统服务未做更改.
if /I %SELECT%=="/relan" echo LAN 设置已激活.
if /I %DHCP_CHANGES%=="YES" (
echo.
echo DHCP重要注意事项
echo =====================
echo 你的配置预示着 DHCP 服务将不再需要使用.
echo 但是如果你使用 XDSL 尝试联接到网络时可能会产生错误.
echo 如果你在联接到网络期间遇到此故障,请重新将DHCP服务
echo 激活为"手动".
echo.
)
echo 请重新启动.
echo ______________________________________________________
)
:QUIT
echo ________________________________________________________
echo.
echo.
echo 详细信息请登陆: [url]http://www.ntsvcfg.de/ntsvcfg_eng[/url]
echo ________________________________________________________
echo [按任意键退出]
echo ------------------------------------------------------
echo.
if /I "%1"=="" pause>NUL
:QUIT_EXT
endlocal
if exist "%USERPROFILE%\ntsvcfg\svc2cmp.sav" del /F /Q "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
echo.
|