Windows Vista/7 启动时空格键的妙用

  与Windows XP相比,Vista在启动选项的开启上也略有不同。在XP中,用户必须通过按F8的方式来打来启动选项,而在Vista中,这一方法依然有效,但同时,用户也可以通过按空格键的方式来达到同样的效果。另外,作为Vista的继任者,Windows 7也将继承这一传统,在BIOS加载完毕后轻按空格键即可呼出Windows 启动管理器。
  “在Windows Vista或Windows Server 2008中除了按F8外,还有一些其他的方法可以用来打开启动选项。下次重启时,你可以试试在BIOS加载完毕后,Windows启动画面出现前按下空格键。如果你正好在那时按下了空格键,Windows启动管理器就会出现了。此时,用户可以任意选择OS,或者按下F8打开还原菜单等等。”
  当然,在Windows 7中,当用户按下F8时,系统还原菜单就会出现。同时,还会有F10按键供用户打开启动参数编辑器。不过,参数管理器只是暂时性的,更多的选项还要借助于msconfig。
  “这种方法也可以用在Vista或Server 2008的安装光盘上。就在系统提示“按任意键从CD/DVD启动”时,轻按2、3下空格键,此时,Windows启动管理器将再次出现,同时,列表中也会出现Windows安装选项。"

Windows Vista 22类问题解决方法

  Vista发而已经很久了,现在给大家整理一些相关的问题。

1. 如何关闭UAC?
  控制面板→用户帐户→打开或关闭用户账户控制→取消使用用户账户控制(UAC)帮助保护您的计算机。

2. 如何关闭系统备份与还原?
  控制面板→备份和还原中心→创建还原点或更该设置→系统保护→自动还原点→取消已经选中的磁盘上的还原点。

3.为什么在某个固定的时间会出现狂读硬盘的现象?
  这是因为Vista自动执行磁盘碎片整理计划的缘故,关闭的方法是通过开始菜单→附件→系统工具→磁盘碎片整理程序→取消“按计划运行(推荐)”

4. 如何关闭计算机进入休眠状态?
  桌面右键→个性化→屏幕保护程序→更改电源设置→更改计算机的睡眠时间→使计算机进入睡眠状态设为从不。

5. 开始菜单电源按钮默认设定为“休眠”,如何更改为“关机”?
  控制面版→电源选项→选中的“首选计划”→更改计划设置→更改高级电源设置,在弹出的设置窗口中找到“电源按钮和盖子”→“开始”菜单电源按钮→设置→关机,确定即可 完成设置。

6.每次开机时在安全中心都会提示,如何关闭这个提示信息?
  控制面板→安全中心→更改安全中心通知我的方法→选择不通知我,但显示图标。

7. 如何在非传统开始菜单中显示运行命令?
  任务栏和开始菜单属性→开始菜单→自定义→选中“运行命令”。

8.如何取消每次开机的默认共享?
  将下列内容导入注册表,重启即可(前提是要关闭UAC)。
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Lanmanserver\Parameters]
AutoShareWks=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
restrictanonymous=dword:00000001

9.如何实现自动登陆?
  开始→运行→输入“rundll32 netplwiz.dll,UsersRunDll”命令打开帐户窗口,先选中要自动登陆的账户,去选“要使用本机,用户必须输入用户名密码”复选框,输入该帐户的 密码即可(前提是要关闭UAC)。

10. 如何更改媒体文件使用WMP以外的播放器播放?
  选中媒体文件→右键菜单→打开方式→选择默认程序→选择播放程序→选中“始终使用选择的程序打开这种文件”。

11. 为何我无法实现局域网互访?
  从以下几个方面入手:
  本地连接→右键属性→取消Internet协议版本6,缩短验证时间。
  检查机器工作组名称是否一致。
  检查机器IP是否在同一网段,如192.168.1.X。
  将网络和共享中心→网络连接→自定义→位置类型设置为专用,降低保护。

12.开启ICF后局域网内机器如何实现互访?
  Windows防火墙取消阻止所有传入连接,并在“例外”中选中“文件和打印机共享”。

13.如何实现用管理员(Administrator) 账户登陆?
  计算机→管理→本地用户和组→用户→Administrator账户→属性→取消账户已禁用选项,当前使用账户→属性→选中账户已禁用选项。

14. 打开控制面板报错“Windows资源管理器已经停止工作”,要如何修复?
  硬件驱动冲突,可能和声卡驱动有关,尝试重新安装声卡驱动。

15. 如何快速复制文件、文件夹路径?
  按 Shift 键,右键需要复制路径的文件、文件夹或快捷方式等,在弹出菜单里面有一项复制为路径(A),点击后可复制该文件、文件夹路径。

16. 如何察看系统许可信息?
  运行slmgr.vbs -dlv。

17. 文件反向选择的快捷键是什么?
  ALT+E弹出菜单后按I。

18.如何更改桌面上的图标的大小?
  Ctrl+鼠标滚轮或者桌面右键→查看→经典图标。

19.如何使用3D方式切换程序?
  在开启Aero外观的情况下,使用Win(视窗键)+Tab可以使用3D方式切换程序,Win(视窗键)+Ctrl+Tab可以使程序3D窗口暂时停留在桌面上。

20.如何设置IE浏览器代理?
  打开IE工具栏的Internet选项→连接→拨号和虚拟专用网络设置中选中您的拨号连接→设置,在“设置”页面中,选中“对此连接使用代理服务器”然后在“地址”栏中填上代理 服务器地址和端口,单击“确定”。

21. 如何查看某个进程的PID值?
  任务管理器→查看→选择列中可以进行选择。

22. 如何实现退出系统时清除最近打开的文档的历史?
  运行gpedit.msc,用户配置→管理模板→『开始』菜单和任务栏→退出系统时清除最近打开文档的历史,设为已启用就可以了。

Windows Vista 解决不能 Ping 的问题

  今天有朋友在论坛里面提到这么一个问题,他的一台Vista 旗舰版的电脑,能够上网,也能够上QQ,却不能ping,无论ping内网还是外网地址都不通,均提示"一般故障"。但是,在Windows XP下面,却一切正常。
  确实怪了去了,网络明显是通的,而且只能ping通 127.0.0.1 这个本机,连他的网管 192.169.1.1 都ping不通。为什么在Windows Vista下面不能使用Ping这个命令呢?
  先把这位朋友遇到的问题显示如下:
C:\>ping 192.168.1.1
正在 Ping 192.168.1.1 具有 32 字节的数据:
一般故障。
一般故障。
一般故障。
一般故障。
192.168.1.1 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失)
  实际上,这个问题,还是因为Vista系统自带的Windows防火墙所造成的,需要在 Windows 防火墙里开启icmp传入和传出的策略。
  注意,必须以管理员身份进行登录,才能执行以下这些步骤。
  若要查找 ICMP 和日志记录设置,请打开带高级安全的 Windows 防火墙。
  1、单击打开“管理工具”。‌ 如果系统提示您输入管理员密码或进行确认,请键入密码或提供确认。
  2、双击“高级安全的 Windows 防火墙”。
  3、在“公用配置文件”下,单击“Windows 防火墙属性”。
  1)单击要更改的配置文件的选项卡。
  1)在“日志记录”下,单击“自定义”。
  在出现的对话框中,更改需要更改的设置,然后单击“确定”。
  可以使用 ICMPv4 或 ICMPv6 协议创建入站或出站规则,从而指定 ICMP 设置。

Windows Vista 语言包(MUI)下载大全

  MUI就是多语言用户界面包:MUI 提供一个已翻译大部分用户界面的版本,MUI 只在Windows Vista Ultimate和Windows Vista Enterprise中使用。
  还有一种语言界面包是LIP,语言界面包 (LIP):Windows Vista LIP 提供一个已翻译用户界面的最广泛使用部分的版本。LIP 可以从 Microsoft 网站免费下载,并且大部分的 LIP 可以在任何版本的 Windows Vista 上安装和使用。因为并不是所有的用户界面都已翻译,所以 LIP 至少需要一种“父语言”。未翻译为 LIP 语言的用户界面部分会用父语言显示。下载 LIP 时,就向您提供了该语言的父语言要求。需要先安装父语言包,之后才能安装 LIP。
  现在提供的是 Windows Vista 多语言用户界面包(MUI),因此只能在 Windows Vista Ultimate 和 Windows Vista Enterprise 中安装。之前安装了英文版的用户就不必重新安装中文版了,安装这个中文语言包即可成为双语系统,安装其他语言包还可以成为多语言系统。
  Vista RTM中可以通过Windows更新下载各语言包文件,这些下载地址曾经一度消失过,微软也曾经就此事做过解释。但是,不知道为什么在安装Vista SP1之后,这些语言包一样会消失,如果各位需要它们的话,可以通过这些地址直接下载。
1、Vista Ultimate x86 MUI 语言包2、Vista Ultimate x64 MUI 语言包

Windows 2000/XP/Server 2003/Vista/Server 2008 系统中如何做到安全刻录

  现在软件越做越大,面对目前越来越大的数据的处理量,再随着光盘刻录机和CD-R的价格连续下跌,许多用户都购置了光盘刻录机,并用它来刻录、永久保存数据,确实是大大方便了数据的存储。我也购置了一台刻录机,使用的刻录软件为Nero,愿将使用过程中血的教训总结给广大用户,以告诉大家尽可能多的安全刻录的技巧,减少CD-R的无谓牺牲。
1、关闭能源管理
  一般刻录光盘的时间较长,如果设置了能源管理,可能会导致计算机长时间停止响应,从而导致刻盘失败。所以首先要关闭能源管理,关闭能源管理要从两方面入手:一是以CMOS中将Power Management中的Power Saving设置为NONE;二是进入Windows的“控制面板”,双击“电源管理”图标,将“系统等待状态”、“关闭监视器”及“关闭硬盘”的内容均从下拉列表中选择 “从不”,单击“确定”按钮返回。如果您嫌下一次再次设置麻烦的话,可以将它存盘为“光盘刻录”方案。
2、安装刻录软件前整理硬盘并将文件放置到硬盘的某一分区上
  现在的光盘刻录机都是从硬盘上将数据先读入到刻录机的缓存中去,然后再从缓存中写到CD-R上的,因此,如果硬盘上的数据放置比较混乱,从硬盘上读取数据的时间将会增长,这样可能造成光盘刻录机的缓存中缺少数据的结果,这时候就会引起 Buffer underruns错误,即“操作超时”,造成刻盘失败。不仅硬盘上的数据放置比较混乱会引起上述错误,而且如果一些文件不放置在同一分区的连续区域内也极有可能发生此类错误,(我曾经有过此类经历)因此,最好在刻录光盘之前做到以下几点:
  2.1.删除不必要的文件,以腾出足够的硬盘空间;
  2.2.将所有的文件全部拷贝到某一硬盘的某一分区上;
  2.3.在将要刻录之前,最好运行硬盘扫描程序,以保证所有的文件放置在连续的区域上,不过,我是不建议您使用微软件Windows中自带的磁盘扫描程序Scandisk,它的速度比较慢,而且很容易出错,推荐你使用Vop99磁盘扫描软件,此软件扫描修复磁盘速度极快,而且较稳定,支持多个驱动器的扫描及自动扫描,它可以从www.goldenbow.com上免费下载使用。
3、在刻盘前关闭所有其它应用程序
  由于刻盘是一项很消耗系统资源的工作,所以在往CD 盘中写数据时,必须关闭关闭所有其它应用程序及任何FAX Modem、电子邮件和屏幕保护以及其它应用程序,如果登录了网络,要退出网络环境或者暂时移去网络功能。

Windows Vista 组策略巧用八则

注册表是Windows系统中保存系统、应用软件配置的数据库,随着Windows系统功能的越来越丰富,注册表里的配置项目也越来越多,其实很多配置都是可以自定义设置的,但这些配置发布在注册表的各个角落,如果是手工配置是非常困难和烦杂的。而“组策略”则是将系统重要的配置功能汇集成各种配置模块,供管理人员直接使用,从而达到方便管理计算机的目的。也就是说,修改“组策略”就是修改注册表中的配置。下面我们就在Vista系统下利用“组策略”完成一些看似很难完成的任务。
1.让“运行”在开始菜单中现身
  熟悉DOS的朋友们经常会调用黑底白字的命令行窗口进行DOS操作,但Vista开始菜单中却不见了“运行”项的踪影,虽然“开始”菜单的“搜索”框可以当作“运行”框来用,或者单击“开始”→所有程序→附件→运行,可以打开“运行”窗口,但既使是初试Vista系统的“老鸟”也感到不适。这时我们可以单击“开始”→所有程序→附件→运行,在打开的“运行”对话框中输入gpedit.msc后回车,启动“组策略”对话框。在“组策略”对话框的左侧窗格中单击“用户配置”→管理模板→开始菜单和任务栏,然后到右侧窗格中双击“将运行命令添加到[开始]菜单”项,在打开的“将运行命令添加到[开始]菜单属性”对话框中的“设置”选项卡下选择“已启用”,然后点“确定”退出,这样“运行”就会在“开始”菜单中现身了。
2.关闭“气球”通知
  有时当你正在工作时突然冒出一段提示语,逼着你必须去点击一下,让人非常讨厌。其实我们在打开的“组策略”对话框中的左侧窗格中依次单击“用户配置”→管理模板→开始菜单和任务栏,然后到右侧窗格中双击“关闭所有气球通知”项,在打开的“关闭所有气球通知属性”对话框中的“设置”选项卡下选择“已启用”,然后点“确定”退出,就能把让人讨厌的“气球通知”关掉了。
3.记录上次登录Vista系统的时间
  Vista系统能记录下我们的登录信息,这样每次登录系统时就可以将前后两次登录的时间做一对比,如果发现时间不一致,就说明有人曾经试图非法登录过你的账户。其实在打开的“组策略”对话框中的左侧窗格中依次单击“计算机配置”→管理模板→Windows组件→登录选项,然后到右侧窗格中双击“在用户登录期间显示有关以前登录的信息”项,在打开的“在用户登录期间显示有关以前登录的信息属性”对话框中的“设置”选项卡下选择“已启用”,然后点“确定”退出。这样下次启动计算机时,Vista系统就会在用户进入系统桌面前提示你上次的登录时间了(如图)。
4.给系统管理员账户Administrator重命名
  大家都知道系统管理员账户Administrator拥有最高权限,也正因如此一些病毒和木马程序总是利用这个大家都知道的账户名——Administrator制造事端,其实我们也可以给它改一下名,从而让那些局外人无从下手。在打开“组策略”对话框的左侧窗格中依单击“计算机配置”→Windows设置→安全设置→本地策略→安全选项,然后到右侧窗格中双击“账户:重命名系统管理员账户”项,在新打开的“账户:重命名系统管理员账户属性”对话框中就可以给系统管理员账户Administrator改一个名了。
5.限制、隐藏磁盘分区
  为了使用方便,我们有时也在多人共用的公用电脑中存放一些属于个人隐私级别的数据资料,为了保证这些数据的安全,可以通过对磁盘分区进行限制或隐藏来实现对数据的保护。
  在打开“组策略”对话框的左侧窗格中依次单击“本地计算机策略”→用户配置→管理模板→Windows组件→Windows资源管理器,然后到右边的窗格中双击“防止从‘我的电脑’访问驱动器”项,接着在打开的“防止从‘我的电脑’访问驱动器的属性”设置窗口中选择 “已启用”,选择“已启用”后,在下面会出现选择驱动器的下拉列表,选择我们希望限制的驱动器后点“确定”即可。
  如果希望关闭所有的驱动器,包括光驱等,可以选中“限制所有驱动器”。在“Windows资源管理器”下还有“隐藏‘我的电脑’中的这些指定的驱动器”这项,通过该策略可以隐藏指定的驱动器,但是这个策略可以通过IE浏览器突破,在地址栏中输入C:\回车就可以打开隐藏的C盘分区,为此相比之下我们还是用“限制”更好一些。
6.给“关闭计算机”再加一把“锁”
  在单位中临时有时需要暂时离开电脑时,为防止别人偷窥电脑上的资料,我们可以通过WIN+L快捷键来锁定计算机,但是在锁定页面上还能执行“关闭计算机”,虽然他人无法乱动机器了,但是却可以关机,为此有必要再给“关闭计算机”再加一把“锁”。在打开的“组策略”对话框中的左侧窗格中依次单击“计算机配置”→Windows设置→安全设置→本地策略→安全选项,然后到右侧的窗格中找到并双击“关机:允许在未登录前关机”项,在弹出来的属性对话框中将其属性设置为“已禁用”后,点击“确定”即可。
7.防止密码被猜中
  当我们的Vista 用户口令设置比较简易时,非法用户很容易通过多次重试“猜”出用户密码而登录系统,其实我们可以限制“猜”的次数,当某一用户尝试登录系统输入错误密码的次数达到一定阈值即自动将该账户锁定,在账户锁定期满之前,该用户将不可使用,除非管理员手动解除锁定。在打开“组策略”对话框的左侧窗格中依次单击“计算机设置”→Windows设置→安全设置→账户策略→账户锁定策略,然后到右侧窗格中的“账户锁定阈值”项,这里可以设置用户账户被锁定的登录尝试失败的次数,该值在0到999之间,默认为0表示登录次数不受限制,我们可以改为3或10。
8.取消开始菜单中的“注销”
  在打开的“组策略”对话框中的左侧窗格中依次单击“用户配置”→管理模板→开始菜单和任务栏,然后到右侧窗格中双击“删除[开始]菜单上的‘注销’”项,在打开的“删除[开始]菜单上的‘注销’属性”对话框中的“设置”选项卡下选择“已启用”,然后点“确定”退出。这样“注销”项就会在开始菜单中消失了。但这样设置仅对“开始”菜单起作用,并不影响“Windows 安全性”对话框(可以按 Ctrl+Alt+Del打开)上的“注销”项目。

Windows 2000/XP/Server 2003/Vista/Server 2008 垃圾清理批处理

这个批处理是蓝蓝小雪根据网上流传很广的一个批处理进行修改、增强得到的。把下面内容复制到记事本中,保存的时候的文件名请输入成"cleansys.bat"(注意引号),然后就可以运行了。请在开始清理前先关闭所有其他程序(特别是 Internet Explorer 等程序),并注意使用管理员模式运行本程序。
@echo off
echo Windows 博客(WIN.Snow518.CN)特别提醒:
echo   请在开始清理前先关闭所有其他程序(特别是 Internet Explorer 等程序),并注意使用管理员模式运行本程序。
echo   做到这些之后请按任意键继续 . . .
pause > nul
echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo.
echo Windows 博客(WIN.Snow518.CN)正在帮您清除系统垃圾文件,请稍等......
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%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
rd /s /q %temp% & md %temp%
del /f /s /q "%userprofile%\recent\*.*"
echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo.
echo Windows 博客(WIN.Snow518.CN)报告:清除系统垃圾完成!
echo. & pause

Windows 2000/XP 优化批处理

这个代码支持多种模式。把下面内容复制到记事本中,保存的时候的文件名请输入成"svc2kxp.cmd"(注意引号),然后就可以运行了。非 Windows 2000 或 XP 请不要尝试。 @echo off
cls
rem Copyright (C) 2003-05 Ansgar Wiechers & Torsten Mann
rem Contact: admin@ntsvcfg.de
rem
rem This program is free software; you can redistribute it and/or modify it under
rem the terms of the GNU General Public License as published by the Free Software Foundation;
rem either version 2 of the License, or (at your option) any later version.
rem This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
rem without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rem See the GNU General Public License for more details.
rem
rem You should have received a copy of the GNU General Public License along with this program;
rem if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
rem MA 02111-1307, USA.
echo.
REM Tested on ... WinXP_SP2
REM Always basic XP64 Support
REM Modifications to BITS service (cause of v5 WindowsUpdate) - #discharged#
REM Additional notices corresponding to DHCP issue
REM Variables problems during RESTORE_DEFAULT usage fixed
REM SMBDEVICEENABLED Restore Bug fixed
REM Mod_history-09-27-2005**11-08-2005**11-29-2005**12-07-2005**12-18-2005

setlocal

REM *** INIT_VARS ***
set CHK_SVC=YES
set XPSP2=FALSE
set SERVER=FALSE
set NT_SERVER_CHK=TRUE


:START
echo  "svc2kXp.cmd" v2.2_build7b (18.12.2005), published under GNU GPL
echo  ================================================================
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 "%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
goto :VERSION

:SYNTAX
echo.
echo.
echo  !!Syntax error!!
echo  ________________
echo  Es kann nur ein oder kein Parameter angegeben werden.
echo.
echo  Only one or no parameter allowed.
goto :QUIT

:HELP
echo.
echo                                 -= Hilfe =-
echo  Parameter:
echo  /lan.......Einige Dienste fuer LAN-Betrieb werden nicht veraendert.
echo  /std.......Schliesst alle Ports, einige Dienste bleiben unveraendert.
echo  /all.......Setzt alle Vorschlaege nach www.ntsvcfg.de um (hardening).
echo  /restore...Nimmt die zuletzt vorgenommenen Aenderungen zurueck.
echo  /reLAN.....Reaktiviert Dienste, die fuer LAN-Betrieb benoetigt werden.
echo  /default...Setzt alle Diensteinstellungen auf urspr黱gliche Werte zur點k.
echo.
echo  Parameters:
echo  /lan.......Some services needed for LAN-usage stay unchanged!
echo  /std.......Closes all Ports, but some services stay unchanged
echo  /all.......Changes all issues recommended by www.ntsvcfg.de ("hardening")
echo  /restore...Undo last changes.
echo  /reLAN.....Reactivates services required for LAN.
echo  /default...Restoring factory service settings (before first time usage)
echo.
echo  example: svc2kxp.cmd /all
echo.
set /P CHS= [Press "G" for GNU GPL informations or "Q" for quit]?
if /I "%CHS%"=="G" goto :GNU_GPL
if /I "%CHS%"=="Q" goto :QUIT_EXT
CLS
goto :HELP

:GNU_GPL
CLS
echo  Informations about GNU-General Public License for "svc2kxp.cmd"
echo  ===============================================================
echo.
echo  Copyright (C) 2003-05 Ansgar Wiechers, Torsten Mann
echo  Contact: admin@ntsvcfg.de
echo.
echo  This program is free software; you can redistribute it and/or modify it under
echo  the terms of the GNU General Public License as published by the Free Software
echo  Foundation; either version 2 of the License, or (at your option) any later
echo  version. This program is distributed in the hope that it will be useful, but
echo  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
echo  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
echo  details.
echo.
echo  You should have received a copy of the GNU General Public License along with
echo  this program; if not, write to the:
echo.
echo  Free Software Foundation, Inc.
echo  59 Temple Place, Suite 330
echo  Boston, MA 02111-1307, USA.
echo.
set /P CHS= [Press "H" for help or "Q" for quit]?
CLS
if /I "%CHS%"=="H" goto :HELP
if /I "%CHS%"=="Q" goto :QUIT_EXT
goto GNU_GPL

:VERSION
echo  Checking system version ...


if /I "%NT_SERVER_CHK%"=="FALSE" goto :SKIP_NT_SERVER_CHK
REM Checking for running server version
        "%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
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  !!Failed!!
echo  __________
echo.
echo  Dieses Script ist nur unter Windows 2000 oder XP lauffaehig!
echo.
echo  This script works only on Windows 2000/XP machines!
echo.
goto :QUIT

:NOFIND
echo.
echo  !!Failed!!
echo  __________
echo.
echo  Leider konnte folgende Datei nicht gefunden werden:
echo.
echo  Sorry, but following file is missing:
echo.
echo.
echo  # %SystemRoot%\System32\FIND.EXE
echo.
echo.
goto :QUIT

:NOREGEDIT
echo.
echo  !!Failed!!
echo  __________
echo.
echo  Leider konnte folgende Datei nicht gefunden werden:
echo.
echo  Sorry, but following file is missing:
echo.
echo.
echo  # %SystemRoot%\REGEDIT.EXE
echo.
echo.
goto :QUIT

:NTSERVER
echo.
echo  !!Failed!!
echo  __________
echo.
echo  Dieses Script unterstuetzt keine NT Server Versionen!
echo.
echo  This script doesn't support NT server versions!
echo.
goto :QUIT


:OS2K
rem Specific OS Detection I
set SYSTEM=2k

rem Testing for XP ServicePacks

        "%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 (

                                        echo  !Windows 2000 [no or unknown Service Pack] detected!
                                        goto NO_2KSP
                                        )

                                echo  !Windows 2000 [Service Pack 1] detected!
                                  goto :NO_2KSP
                                )


                        echo  !Windows 2000 [Service Pack 2] detected!
                          goto :NO_2KSP
                        )


                echo  !Windows 2000 [Service Pack 3] detected!
                goto :NO_2KSP
                )


        echo  !Windows 2000 [Service Pack 4] detected!
        goto :NO_2KSP

:NO_2kSP
if exist "%TEMP%\~svclist.txt" del /F /Q "%TEMP%\~svclist.txt"
goto :CONTINUE


:OSXP
rem Specific OS detection II
set SYSTEM=xp
rem Testing for XP ServicePack 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  !Windows XP [no or unknown Service Pack] detected!
                        goto NO_XPSP
                        )

                SET XPSP2=FALSE
                  echo  !Windows XP [Service Pack 1] detected!
                  goto :NO_XPSP
                )

        SET XPSP2=TRUE
        echo  !Windows XP [ServicePack 2] detected!
        goto :NO_XPSP

:OSXP64
rem Specific OS detection II
set SYSTEM=xp
rem Testing for XP ServicePack 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 [no or unknown Service Pack] detected!
                        goto NO_XPSP
                        )

                SET XPSP2=FALSE
                  echo  !EXPERIMENTAL! Windows XP64 [Service Pack 1] detected!
                  goto :NO_XPSP
                )

        SET XPSP2=TRUE
        echo  !EXPERIMENTAL! Windows XP64 [ServicePack 2] detected!
        goto :NO_XPSP


:NO_XPSP
if exist "%TEMP%\~svclist.txt" del /F /Q "%TEMP%\~svclist.txt"
goto :CONTINUE


:CONTINUE

REM Creating subdirectory "ntsvcfg" in userprofile if necessary
if not exist "%USERPROFILE%\ntsvcfg\*.*" mkdir "%USERPROFILE%\ntsvcfg"

REM Moving old script backup files to ...\%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 *****Declarations*****
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 *****Options*****
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 *****APP_PATHs******
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  Checking available permissions: [local], please wait ...
"%net%" user "%USERNAME%" 2> nul | "%find%"  /i "admin" | "%find%"  /i /v "name" > nul
if errorlevel 1 (
        echo     "         "          "     : [domain], please wait ...
        "%net%" user "%USERNAME%" /domain 2> nul | "%find%"  /i "admin" | "%find%"  /i /v "name" > nul
        if errorlevel 1 (
                echo.
                echo  Failed!
                echo  __________
                echo  Leider verfuegen Sie nicht ueber die erforderlichen Rechte!
                echo  Melden Sie sich bitte als Administrator an.
                echo.
                echo  Sorry but you don't have the permissions required for this task.
                echo  Please login as Administrator.
                echo.
                goto :END
                )
        )

set IMPORT_OLD_FILES=FALSE
rem searching for sc.exe
if not exist "%FPRINT%" echo  Checking for presence of SC.EXE ...
"%sc%" qc > nul 2>&1
if errorlevel 1 (
        echo  !!Failed!!
        echo  __________
        echo  Die notwendige Datei SC.EXE konnte leider nicht unter
        echo  [%SystemRoot%\SYSTEM32\] gefunden werden.
        echo  Bitte laden Sie sich diese Datei von der unten genannten Adresse herunter:
        echo.
        echo  SC.EXE couldn't be found in [%SystemRoot%\SYSTEM32\].
        echo  Please download it from following location:
        echo.
        echo.
        echo            -= ftp://ftp.microsoft.com/reskit/win2000/sc.zip =-
        echo.
        echo                                Self-installing SC.EXE
        echo                                ======================
        echo  svx2kxp.cmd kann versuchen, die notwendige Datei selbst zu installieren.
        echo  Hierzu benoetigen Sie eine bestehende Internetverbindung.
        echo.
        echo  svc2kxp.cmd may try to download the required file SC.EXE itself if an
        echo  active internet connection exists.
        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 checking for modified services
if /I %CHK_SVC%==YES (
        if /I %USE_FPRINT%==YES (
                if exist "%FPRINT%" (
                        rem Creating fingerprint of current service settings...
                        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  Checking for modified services ... failed-services maybe modified! [E]valuate
                        set SVC_MOD=YES
                        goto :MOD_END

                        :OK
                        echo  Checking for modified services ... 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                            -= Auswahl / Overview =-
echo.
echo  Bitte waehlen sie einen Punkt aus, den sie ausfuehren moechten:
echo.
echo  (1) LAN:       Einige Dienste fuer LAN-Betrieb werden nicht veraendert.
echo  (2) Standard:  Schliesst alle Ports, aber einige Dienste bleiben unveraendert.
echo  (3) ALL:       Setzt alle Vorschlaege nach www.ntsvcfg.de um (hardening).
echo  (4) Restore:   Nimmt die zuletzt vorgenommenen Aenderungen zurueck.
echo  ______________________________________________________________________________
echo.
echo  Please choose one task you want to do:
echo.
echo  (1) LAN:       Some services needed for LAN-usage stay unchanged
echo  (2) Standard:  Close ports but some services stay unchanged
echo  (3) ALL:       Making all changes described at www.ntsvcfg.de (hardening)
echo  (4) restore:   Restores last changes made.
echo.
set /P CHS= Bitte waehlen Sie/Please choose: [1],[2],[3],[4], [M]ore options or [Q]uit?

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 Checking if old restorefiles exists.
rem if it is so old files will be restored before new changes
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  [Selected Restore Mode: %RESTORE_MODE%]
echo.
echo  # Achtung: Alte Sicherungsdateien gefunden!
echo.
echo     "Svc2kXp.cmd" wurde schon einmal ausgefuehrt. Damit neue Aenderungen
echo     korrekt durchgefuehrt werden koennen, werden die Sicherungsdateien
echo     eingespielt.
echo.
echo.
echo    Attention: old restore-files found!
echo.
echo     This program runs not for the first time. To apply all new changes
echo     correctly old restore files will used to get an definite state.
echo.
echo.
echo  # Starting restore ...
goto RESTORE_EXT



:NO_RESTORE
rem query if taskplaner should run
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  Rueckfrage / Query
echo  ==================
echo.
echo  Soll der Dienst "Taskplaner" beendet werden?
echo.
echo  Wenn sie zeitgesteuerten Aufgaben [z.B. Antiviren-Updates] oder die automati-
echo  sche Erstellung von Systemwiederherstellungspunkten nicht benoetigen, druecken
echo  Sie eine BELIEBIGE TASTE, um auch Port 135 [RPC] sowie Port 1025 [Taskplaner]
echo  zu schliessen [empfohlen!]. Andernfalls druecken Sie "N"!
echo.
echo.
echo  Should the "scheduler service" be disabled?
echo.
echo  If you have time-controlled tasks [i.e. AV-Updates] or you will not set
echo  automatic system restore points press ANY KEY TO CONTINUE to close port 135
echo  [RPC] and port 1025 [scheduler] instantly. Otherwise press "N"
echo  ___________________________________________
echo.
set /P UNDO= Taskplaner beenden - Close scheduler [y/n]?
if /I "%UNDO%"=="n" set SCHEDULER_ENABLED=YES



:SKIP_SQUERY

if not exist "%SVC_BAK%.default" (
        echo.
        echo  Creating backup of defaults ...
        "%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
        echo                             ... done.
        )

if exist "%SVC_BAK%" (
        if /I %RESTORE_MODE%==2 goto :SKIP_SAVING
        if /I %RESTORE_MODE%==4 goto :SKIP_SAVING
        )

rem saving registry settings
echo  _________________________________________________________________________
echo.
echo  [Selected Restore Mode: %RESTORE_MODE%]
echo.
echo     Saving services settings to
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     Saving DCOM standard protocols settings to
echo       %DCOMP_BAK% ...
"%regedit%" /e "%DCOMP_BAK%" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc
echo     Saving SMB settings to
echo       %SMB_BAK%
"%regedit%" /e "%SMB_BAK%" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
echo     Saving URL-Handler [AIM, GOPHER, TELNET] to
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  All done.
echo  ___________________________________________
echo.


:SKIP_SAVING

if /I "%SYSTEM%"=="xp" (
        if /I %UseXPSysRestore%==YES (
                goto :XPSYSRESTORE
                )
        )
:XPSYSRESTORE_DONE

rem reconfigure services
rem startup: demand
echo.
echo  Setting services to "demand" ...

echo  ___________________________________________
echo.
echo  # Checking DHCP ...
"%ipconfig%" -all | "%find%"  /i "Lease" > nul
if errorlevel 1 (
        rem trying other method for DHCP
        "%ipconfig%" -all | "%find%"  /i "DHCP-Server" > nul
        if errorlevel 1 (
          echo                ... no active DHCP found.
          echo.
  echo  Hinweis
  echo  =======
  echo  Ihre Konfiguration deutet an, das kein DHCP benoetigt wird. Falls
          echo  Sie dennoch einen DSL-Internetzugang besitzen und DHCP irrtuemlich 
  echo  deaktivert wurde, kann es nach einem Neustart zu Problemen mit der 
  echo  Internetverbindung kommen. Starten sie zur Problembehebung den 
  echo  DHCP-Dienst manuell neu.
  echo.
  echo  Notice
  echo  ======
  echo  Your configuration indicates that DHCP no longer will be required.
  echo  But if you use a DSL internet connection this choice probably 
          echo  might be wrong. If you experiences problems during accessing the 
  echo  internet please re-activate the "DHCP Service" manually.
  echo.
  echo  ___________________________________________
  echo.
          "%sc%" config DHCP start= demand
          goto :SKIP_DHCP
        )
)
set DHCP_CHANGES="NO"
echo  ... DHCP active, status of service will NOT be changed!
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 If XP SP2 is installed there are less changes to 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 startup: auto
echo  Setting services to "auto" ...
"%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 startup: disabled
echo  Setting services to "disabled" ...
"%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  XPSP2: Disabling Security Center ...
                "%sc%" config wscsvc start= disabled
                )
        )


echo.
echo  ------------------
echo  # Checking and stopping unnecessary system services ...
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  Disabling 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  Disabling DCOM standard protocols ...
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  Disabling port 135 (maybe 1025 too) ...
   echo    - Removing RPC Client Protocols
   echo REGEDIT4 > "%SMB_TMP%"
   echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\ClientProtocols] >> "%SMB_TMP%"
   echo. >> "%SMB_TMP%"

   if /I %SCHEDULER_ENABLED%==NO (
    echo    - Advanced RPC Configuration
    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    - Advanced RPC Configuration
    echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet] >> "%SMB_TMP%"
    echo "PortsInternetAvailable"="N" >> "%SMB_TMP%"
    echo "UseInternetPorts"="N" >> "%SMB_TMP%"
    echo. >> "%SMB_TMP%"
    )

   echo    - Removing needless URL Handler [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  Disabling SMB port 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  Disabling SMB port 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.  Due problems with SP2 and deactivating NetBIOS this option
                echo   will be skipped.
                echo.
                goto :SKIP_NB_DISABLE
                )

  rem Because of problems with SP2 Netbios:
  if /I %XPSP2%==True (
                echo.
                echo  Note:
                echo  -----
                echo  If you experiencing problems after updating Windows XP with
                echo  Service Pack 2 please do following:
                echo.
                echo                          set Deactivate_NetBIOS=NO
                echo.
                )
  rem *** Thx2 Johannes Lichtenberger for the following lines using VBScript***
  echo  Disable NetBios on all local interfaces ...
  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 Skip Billboard because /all is used
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                   *** Zusammenfassung / Result ***
echo.
echo  Es wurden NICHT alle Aenderungen umgesetzt!
echo  Um alle Vorschlaege von kssysteme.de umzusetzen, verwenden Sie
echo  bitte den Parameter '/all' oder waehlen Sie im Menue den Punkt "3".
if /I %DHCP_CHANGES%=="YES" (
          echo.
   echo  Wichtiger DHCP Hinweis
   echo  ======================
   echo  Ihre Konfiguration deutete an, das kein DHCP benoetigt wird. Falls
           echo  Sie jedoch einen DSL-Internetzugang besitzen und DHCP irrtuemlich 
   echo  deaktivert wurde, kann es nach einem Neustart zu Problemen mit der 
   echo  Internetverbindung kommen. Starten sie zur Problembehebung den 
   echo  DHCP-Dienst von Hand neu.
   echo.
)

echo.
echo  Not all changes could be performed. To change all issues listed
echo  on www.ntsvcfg.de please use parameter '/all' or select item "3"!
if /I %DHCP_CHANGES%=="YES" (
          echo.
   echo  Important DHCP Notice
   echo  =====================
   echo  Your configuration indicates that DHCP will no longer be required.
   echo  But if you are using a DSL internet connection this choice probably 
           echo  might be wrong. If you experiences problems during accessing the 
   echo  internet please re-activate the "DHCP Service" manually.
echo.
)
echo  ___________________________________________________________________

:SW_ALL

if /I %SELECT%=="/relan" (
        rem startup: auto
        echo.
        echo  ------------------
        echo  Re-enabling services ...
        "%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%" config SharedAccess start= auto
                )


        rem start re-enabled services
        echo.
        echo  ------------------
        echo  [Re]starting services ...
        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%" start SharedAccess
                )

        rem enable SMB port 445
        echo.
        echo  ------------------
        echo  Enabling SMB port 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 Creating fingerprint of current service settings...
if exist "%FPRINT%" del /F /Q "%FPRINT%"
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                                                      ... done.
        )
goto :END


:RESTORE
echo  ____________________________________________________
echo.
echo  Letzte Aenderungen zuruecknehmen [y/n]?
set /P UNDO= Undo last changes [y/n]?
if /I "%UNDO%"=="y" (
        echo  _______________________________________________________________
        echo.
        echo  Hinweis:
        echo  ========
        echo  Moeglicherweise meldet Windows Fehler beim Importieren.
        echo  Ignorieren Sie diese mit Klick auf "OK".
        echo.
        echo  Windows might probably report an error during importing the
        echo  backups. Just ignore this by clicking the "OK" button!
        echo  _______________________________________________________________
        echo  Status:
        echo  -------
        :RESTORE_EXT
        if exist "%SVC_BAK%" (
                echo     Importing services ...
                echo        ["%SVC_BAK%"]
                "%regedit%" /s "%SVC_BAK%"
                set action=""
                )

        if exist "%DCOM_BAK%" (
                echo     Importing DCOM ...
                echo        ["%DCOM_BAK%"]
                "%regedit%" /s "%DCOM_BAK%"
                )

        if exist "%DCOMP_BAK%" (
                echo     Importing DCOM-standard protocols ...
                echo        ["%DCOMP_BAK%"]
                "%regedit%" /s "%DCOMP_BAK%"
                )

        if exist "%SMB_BAK%" (
                echo     Importing SMB-settings ...
                echo        ["%SMB_BAK%"]
         echo   - Removing SMBDeviceEnabled RegKey ...
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     Importing URL_HANDLER AIM ...
                echo        ["%HANDLER1%"]
                "%regedit%" /s "%HANDLER1%"
                )

        if exist "%HANDLER2%" (
                echo     Importing URL_HANDLER GOPHER ...
                echo        ["%HANDLER2%"]
                "%regedit%" /s "%HANDLER2%"
                )

        if exist "%HANDLER3%" (
                echo     Importing URL_HANDLER TELNET ...
                echo        ["%HANDLER3%"]
                "%regedit%" /s "%HANDLER3%"
                )

        rem Skipping back to next state
        if /I "%RESTORE%"=="YES" goto :NO_RESTORE

        echo     Removing RPC Internet key ....
        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 Creating fingerprint of current service settings...
        if exist "%FPRINT%" del /F /Q "%FPRINT%"
        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                                                      ... done.
                )

        echo.
        echo  _______________________________________________________________
        echo.
        echo               *** Zusammenfassung / Result ***
        echo.
        echo  Die Ruecksicherung wurde ausgefuehrt. Wenn in der oberen Zeile
        echo  keine Statusmeldungen zu sehen sind, existierten keine rueckzu-
        echo  sichernden Dateien. Aktivieren Sie gegebenenfalls NetBios in
        echo  den Eigenschaften der jeweiligen Netzwerkkarte.
        echo  Bitte starten Sie abschliessend Ihren Rechner neu.
        echo.
        echo  Restore finished. If you don't see any messages in the status
        echo  box above, there were no files to restore. Please reactivate
        echo  NetBios for each NIC you want use with it and reboot afterwards.
        echo  ________________________________________________________________
        )

goto :END

:RESTORE_DEFAULTS
echo.
echo                     *** Restore Factory Settings ***
echo.
echo  ______________________________________________________________________________
echo.
echo  Einstellungen vor Erstanwendung des Scripts wiederherstellen (ausser NetBIOS)?
set /P UNDO= Restore defaults (before using script, except NetBIOS) [y/n]?
if /I "%UNDO%"=="y" (
        echo.
        echo   - Restoring original service settings [if exists] ...

        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   - Removing SMBDeviceEnabled RegKey ...
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                                                 ... done.

        echo   - Removing RPC Internet key ...
        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                                                 ... done.

        )
goto :QUIT


:SC_DOWNLOAD
echo  ______________________________________________________________
echo.
echo  Besteht eine aktive Internetverbindung?
echo  Are you currently connected to the internet?
echo.
set /P UNDO= Bitte waehlen/Please choose: [y/n]?
  if /I "%UNDO%"=="y" goto :SC_DOWNLOAD_OK
goto :END

:SC_DOWNLOAD_OK
if exist "%SYSTEMROOT%\sc.zip" goto :SCE
echo  Generating FTP-script ...
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 anonymous@aol.com >>"%USERPROFILE%\script_sc.ls"
echo type binary >>"%USERPROFILE%\script_sc.ls"
echo user anonymous anonymous@aol.com >>"%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  Downloading SC.EXE ...
ftp -s:"%USERPROFILE%\script_sc.ls"
del /F "%USERPROFILE%\script_sc.ls"

:SCE
if exist "%SYSTEMROOT%\System32\pkunzip.exe" goto :PKE
echo  Generating FTP-script ...
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 anonymous@aol.com >>"%USERPROFILE%\script_pk.ls"
echo type binary >>"%USERPROFILE%\script_pk.ls"
echo user anonymous anonymous@aol.com >>"%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  Downloading PKUNZIP.EXE ...
ftp -s:"%USERPROFILE%\script_pk.ls"
del /F "%USERPROFILE%\script_pk.ls"

:PKE
if not exist "%SYSTEMROOT%\System32\sc.zip" (
        echo.
        echo   Download fehlgeschlagen. Bitte laden sie sich die Datei SC.ZIP manuell
        echo   herunter und kopieren diese nach %SYSTEMROOT%\.
        echo.
        echo   Downloading SC.ZIP failed. Please download it manually an copy it to
        echo   %SYSTEMROOT%\.
        )

if not exist "%SYSTEMROOT%\System32\pkunzip.exe" (
        echo.
        echo   Die Datei PKUNZIP.EXE konnte nicht gefunden werden. Diese wird zum
        echo   Entpacken des Archivs SC.ZIP benoetigt!
        echo.
        echo   File PKUNZIP.EXE not found. It is needed to decompress the archive 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  Skript wird neu gestartet ...
echo  Restarting script ...
goto :START

:FIX
echo.
echo                     -= svc2kxp.cmd taskplaner fix =-
echo.
echo.
echo  Druecken Sie "Y", um das Problem mit dem Taskplaner ("falscher Parameter")
echo  unter Windows XP zu beheben.
echo.
echo  Press "Y", if you want fix issue "scheduler doesn't start under Windows XP
echo  after running script v2.0 - v2.1build0".
echo.
set /P UNDO= Fix problem [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  OK. Bitte starten Sie den Rechner neu und kontrollieren Sie erneut,
        echo  ob hierdurch Ports geoeffnet wurden.
        echo.
        echo  Done. Please reboot and check again for open ports ...!
        )


rem Creating fingerprint of current service settings...
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                                                      ... done.
        )

goto :QUIT

rem **** Additional Feature List ****

:MORE_OPTIONS
cls
echo  ______________________________________________________________________________
echo.
echo                 *** Weitere Optionen / More Options Menue ***
echo                     =====================================
echo.
if /I "%SVC_MOD%"=="YES" (
        echo  [E]...Zeigt eine Liste an, welche Dienste seit der letzten Anwendung
        echo        von svc2kxp.cmd veraendert wurden.
        echo.
        echo        Shows a list with modified services since last use of scv2kxp.cmd
        echo.
        )

echo  [G]...Generiert einen neuen Fingerprint, um Veraenderungen bei
echo        Diensten zu erfassen
echo.
echo        Generates a new fingerprint to correctly detect changes of
echo        services
echo.
echo  [S]...Sichern der aktuellen Dienstekonfiguration.
echo        Saving current NT service configuration (auto/demand/disabled).
echo.
echo  ______________________________________________________________________________
echo.
if /I "%SVC_MOD%"=="NO" set /P CHS=       Bitte waehlen Sie/Please choose: [G], [S], [B]ack or [Q]uit?
if /I "%SVC_MOD%"=="YES" set /P CHS=       Bitte waehlen Sie/Please choose: [E], [G], [S], [B]ack or [Q]uit?
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 :START
                   )
if /I "%CHS%"=="S" GOTO :SAVE_SVC_SETTINGS
if /I "%CHS%"=="Q" GOTO :QUIT
GOTO :MORE_OPTIONS



:EVALUATE_SERVICES
cls
echo  ______________________________________________________________________________
echo.
echo                        *** Evaluate Services Menue ***
echo.
"%FC%" /N "%FPRINT%" "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
echo  ______________________________________________________________________________
echo.
set /P CHS=       Bitte waehlen Sie/Please choose: [B]ack, [U]pdate or [Q]uit?
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               *** Manage current services configurations menue ***
echo                   --------------------------------------------
echo.
echo   Soll die aktuelle Dienstekonfiguration gesichert werden?
echo.
set /P CHS=  Should the current service configuration saved (y/n)?
if /I "%CHS%"=="N" GOTO :MORE_OPTIONS
if /I "%CHS%"=="Y" (
        echo   Saving current services settings to:
        echo.
        echo    - %SVC_SAV%
        "%regedit%" /e "%SVC_SAV%" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
        echo.
        echo   ... Done!
        echo  ______________________________________________________________________________
        echo.
        echo        Beliebige Taste druecken, um fortzufahren. Hit any key to return.
        pause>NUL
        )
if /I "%CHS%"=="Q" GOTO :QUIT
goto :MORE_OPTIONS




pause >NUL
goto :MORE_OPTIONS


:CREATING_NEW_FINGERPRINT
cls
echo  ______________________________________________________________________________
echo.
echo                     *** Creating new fingerprint menue ***
echo                         ------------------------------
echo.
set /P CHS=  Create new fingerprint [Y/N]?
if /I "%CHS%"=="Y" (
        if exist "%FPRINT%" del /F /Q "%FPRINT%"
        echo   Creating new 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                                                           ... done.
        echo  ______________________________________________________________________________
        echo.
        echo                          [Press any key to continue]
        set CHK_SVC=YES
        PAUSE >NUL
        )
cls
GOTO :MORE_OPTIONS


:XPSYSRESTORE
REM Creating A System Restore Point // Source Code: MS Technet Scriptcenter
        echo.
        echo  # Creating System Restore Point [if XP SysRestore is enabled] ...
        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 created restore point", DEVICE_DRIVER_INSTALL, BEGIN_SYSTEM_CHANGE)>>"%srctmp%"
        "%srctmp%"
        del /F /Q "%srctmp%"
        echo.
goto :XPSYSRESTORE_DONE


:END
if "%REBOOT_REQUIRED%"=="yes" (
        echo.
        echo  ______________________________________________________
        echo.
        echo           *** Zusammenfassung / Result ***
        echo.
        if /I %SELECT%=="/all" echo  Es wurden alle gewuenschten Aenderungen durchgefuehrt.
        if /I %SELECT%=="/std" echo  Einige Dienste blieben unveraendert.
        if /I %SELECT%=="/relan" echo  Notwendige LAN-Einstellungen wurden aktiviert.
if /I %DHCP_CHANGES%=="YES" (
          echo.
   echo  Wichtiger DHCP Hinweis
   echo  ======================
   echo  Ihre Konfiguration deutete an, das kein DHCP benoetigt wird. Falls
           echo  Sie jedoch einen DSL-Internetzugang besitzen und DHCP irrtuemlich 
   echo  deaktivert wurde, kann es nach einem Neustart zu Problemen mit der 
   echo  Internetverbindung kommen. Starten sie zur Problembehebung den 
   echo  DHCP-Dienst von Hand neu.
   echo.
)
echo.
        echo  Bitte starten Sie abschliessend Ihren Rechner neu.
        echo.
        if /I %SELECT%=="/all" echo  All changes applied successfully.
        if /I %SELECT%=="/std" echo  Some services stay unchanged.
        if /I %SELECT%=="/relan" echo  LAN settings reactivated.
if /I %DHCP_CHANGES%=="YES" (
          echo.
   echo  Important DHCP Notice
   echo  =====================
   echo  Your configuration indicates that DHCP will no longer be required.
   echo  But if you are using a DSL internet connection this choice probably 
           echo  might be wrong. If you experiences problems during accessing the 
   echo  internet please re-activate the "DHCP Service" manually.
echo.
)
        echo  Please reboot.
        echo  ______________________________________________________
        )


:QUIT
echo            ________________________________________________________
echo.
echo                 Weitere Informationen: http://www.ntsvcfg.de
echo            For more informations: http://www.ntsvcfg.de/ntsvcfg_eng
echo            ________________________________________________________
echo             [Taste zum Beenden druecken]   [Press any key to quit]
echo             ------------------------------------------------------
echo.
if /I "%1"=="" pause>NUL

:QUIT_EXT
endlocal
if exist "%USERPROFILE%\ntsvcfg\svc2cmp.sav" del /F /Q "%USERPROFILE%\ntsvcfg\svc2cmp.sav"
echo.