win8tools v20131115

从最原先的各个单版本单纯激活软件整合为一个文件,然后又添加了很多其它相关功能,于是有了win8tools这个批处理,致力于整合大量win8、win8.1优化和win server2012、win server2012r2桌面化、设置、优化等功能。
之前一直在各个Q群分布,现在发到网上来,方便各大通过微软正版授权搭建了kms服务器的公司的网管激活本公司授权范围内的系统以及方便个人优化和设置系统。
申明:请勿用于非法用途,后果由使用者自行承担,本人不承担任何责任,此申明在后续更新版本中不再发布,以此文为准。
请将以下代码复制到文本文件中,修改KMSServer=后面的为你公司正版授权kms服务器地址,然后另存为bat文件即可。

@echo off
set KMSServer=这里请设定为你公司正版授权kms服务器地址
set LogFileName=win8tools.error.log

setlocal enabledelayedexpansion

rem 权限检测
echo admintest> %Windir%\System32\admintestfile.txt
if ERRORLEVEL 1 (
echo 请在这个脚本文件上单机鼠标右键,选择“以管理员身份运行”。
pause
exit
)
if exist %Windir%\System32\admintestfile.txt del %Windir%\System32\admintestfile.txt>nul 2>nul
goto main

:main
cls
title Win8 Tools v131115
echo ------ Win8 Tools v131115 ------
echo 说明:
echo     1.请右键以管理员身份运行,如果没有请关闭本窗口重新运行
echo     2.执行完毕之后会有提示,请耐心等待
echo     3.无法激活、工具BUG等反馈交流QQ群:48293344、48221012
echo     4.codeclip.com                                            xy 2013.11.15
echo.
echo ------ 功能选择 ------
echo.
echo     1 自动激活 Windows 和 Office
echo     2 手动激活 Windows 和 Office
echo     3 小工具箱
echo     4 检测 Windows 版本
echo  list 查看可激活系统列表

echo.
set /p choice="请输入对应功能前面的字符串并敲回车:"
if %choice%==1 call :autoat & echo. & echo 按任意键返回... & pause >nul & cls & goto :main
if %choice%==2 call :manualat & echo. & echo 按任意键返回... & pause >nul & cls & goto :main
if %choice%==3 call :tools & echo. & echo 按任意键返回... & pause >nul & cls & goto :main
if %choice%==4 call :checkver & echo. & echo 按任意键返回... & pause >nul & cls & goto :main
if %choice%==list call :list & echo. & echo 按任意键返回... & pause >nul & cls & goto :main
goto :main


:manualat
cls
title KMS 激活
echo ------ KMS 激活 ------
echo 说明:
echo     1.这里只列出了最新的常用系统,其它系统请使用自动激活选项
echo     2.要确定你的系统是否受支持,请查看可激活系统列表
echo.
echo ------ 软件选择 ------
echo.
echo     1 Windows 8.1 Professional
echo     2 Windows 8.1 Enterprise
echo     3 Windows Server 2012 R2 Standard
echo     4 Windows Server 2012 R2 Datacenter
echo     5 Windows 8 Professional
echo     6 Windows 8 Enterprise
echo     7 Windows Server 2012 Standard
echo     8 Windows Server 2012 Datacenter
echo  2010 Office 2010 VL (Office14)
echo  2013 Office 2013 VL (Office15)
echo  list 查看可激活系统列表
echo     0 返回

echo.
set /p choice="请输入对应版本前面的字符串并敲回车:"
if %choice%==1 call :Windows8.1Pro & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==2 call :Windows8.1Enterprise & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==3 call :WindowsServer2012R2Standard & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==4 call :WindowsServer2012R2Datacenter & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==5 call :Windows8Pro & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==6 call :Windows8Enterprise & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==7 call :WindowsServer2012Standard & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==8 call :WindowsServer2012Datacenter & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==2010 call :Office14 & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==2013 call :Office15 & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==list call :list & echo. & echo 按任意键返回... & pause >nul & cls & goto :manualat
if %choice%==0 goto :main
goto :manualat

:tools
cls
title Tools
echo ------ Tools ------
echo 说明:
echo     1.这里的工具大部分兼容64位系统,32位没做测试,欢迎加群交流
echo.
echo ------ 工具选择 ------
echo.
echo     1 修改远程端口并启用远程连接
echo     2 修改远程端口并启用远程连接(WS2003)
echo     3 设定开机自动登陆并锁定系统
echo     4 关闭服务使系统更安全
echo     5 获取网卡MAC地址
echo     6 磁盘清理 - 清理冗余更新(WinSxS冗余)
echo     7 开启任务管理性能选项卡里的磁盘性能监视器
echo     8 开启桌面体验(Desktop Experience)
echo     9 开启无线网络连接(Wireless Networking)
echo     a 开启服务器备份(Windows Server Backup)
echo     0 返回

echo.
set /p choice="请输入对应版本前面的字符串并敲回车:"
if %choice%==1 call :rdp & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==2 call :3389 & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==3 call :AutoLogonAndLockWorkStation & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==4 call :close_service & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==5 call :macfetch & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==6 dism /online  /Cleanup-Image /StartComponentCleanup & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==7 diskperf -y & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==8 PowerShell /Command "&{Add-WindowsFeature Desktop-Experience}" & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==9 PowerShell /Command "&{Add-WindowsFeature Wireless-Networking}" & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==a PowerShell /Command "&{Add-WindowsFeature Windows-Server-Backup}" & echo. & echo 按任意键返回... & pause >nul & cls & goto :tools
if %choice%==0 goto :main
goto :tools


rem 自动激活 Windows 和 Office
:autoat
echo.
echo 准备激活 Windows:
FOR /F "tokens=1,2,* delims= " %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName" 2^>^>%LogFileName%') do set OSNameFromReg=%%k
echo %OSNameFromReg% >>%LogFileName%
set TagNameOS=%OSNameFromReg: =%
call :%TagNameOS% 2>>%LogFileName%
if ERRORLEVEL 1 (
echo 无法激活 %OSNameFromReg%
)
echo.
echo 准备激活 Office:
FOR /F "tokens=1,2,* delims= " %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe" /v "Path" 2^>^>%LogFileName%') do set OfficePath=%%k
if "%OfficePath%"=="" (
echo 没有安装 Office
) else (
FOR /F "tokens=1-5 delims=\\" %%l in ("!OfficePath!") do set OfficeNameFromReg=%%o
set TagNameOffice=!OfficeNameFromReg!
call :!TagNameOffice! 2>>%LogFileName%
if ERRORLEVEL 1 (
echo 无法激活 Office !OfficeNameFromReg!
)
)
goto :eof
exit


rem ----------------------------------------------
:Windows8.1Pro
set Name=Windows 8.1 Pro
set OSName=Windows 8.1 Pro
set ProductKey=GCRJD-8NW9H-F2CDX-CCM8D-9D6T9
call :atos
goto :eof
exit

:Windows8.1Enterprise
set Name=Windows 8.1 Enterprise
set OSName=Windows 8.1 Enterprise
set ProductKey=MHF9N-XY6XB-WVXMC-BTDCT-MKKG7
call :atos
goto :eof
exit

:WindowsServer2012R2Standard
set Name=Windows Server 2012 R2 Standard
set OSName=Windows Server 2012 R2 Standard
set ProductKey=D2N9P-3P6X9-2R39C-7RTCD-MDVJX
call :atos
goto :eof
exit

:WindowsServer2012R2Datacenter
set Name=Windows Server 2012 R2 Datacenter
set OSName=Windows Server 2012 R2 Datacenter
set ProductKey=W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9
call :atos
goto :eof
exit

:Windows8Pro
set Name=Windows 8 Professional
set OSName=Windows 8 Pro
set ProductKey=NG4HW-VH26C-733KW-K6F98-J8CK4
call :atos
goto :eof
exit

:Windows8Enterprise
set Name=Windows 8 Enterprise
set OSName=Windows 8 Enterprise
set ProductKey=32JNW-9KQ84-P47T8-D8GGY-CWCK7
call :atos
goto :eof
exit

:WindowsServer2012Standard
set Name=Windows Server 2012 Standard
set OSName=Windows Server 2012 Standard
set ProductKey=XC9B7-NBPP2-83J2H-RHMBY-92BT4
call :atos
goto :eof
exit

:WindowsServer2012Datacenter
set Name=Windows Server 2012 Datacenter
set OSName=Windows Server 2012 Datacenter
set ProductKey=48HP8-DN98B-MYWDG-T2DCC-8W83P
call :atos
goto :eof
exit

:WindowsServer2008R2Enterprise
set Name=Windows Server 2008 R2 Enterprise
set OSName=Windows Server 2008 R2 Enterprise
set ProductKey=489J6-VHDMP-X63PK-3K798-CPX3Y
call :atos
goto :eof
exit

:Windows7Professional
set Name=Windows 7 Professional
set OSName=Windows 7 Professional
set ProductKey=FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4
call :atos
goto :eof
exit


:atos
rem 激活操作系统
title 激活 %Name%
echo.
echo ------ 激活 %Name% ------
echo.
rem 手动激活需要单独获取一次
if "%OSNameFromReg%"=="" (
FOR /F "tokens=1,2,* delims= " %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName" 2^>^>%LogFileName%') do set OSNameFromReg=%%k
)
rem 如果版本号不匹配,说明用户选择错误,仅针对手动
if not "%OSName%"=="%OSNameFromReg%" (
echo 您选择的版本:%OSName%
echo 您安装的版本:%OSNameFromReg%
echo 系统检测到您选择的和您安装的版本不符,请返回重新选择
goto :eof
)
echo 第一步、设置密钥管理服务计算机名称
ipconfig /flushdns>>nul
cscript /nologo %windir%\System32\slmgr.vbs /ckms>>nul
cscript /nologo %windir%\System32\slmgr.vbs /skms %KMSServer%
echo 第二步、安装产品密钥
cscript /nologo %windir%\System32\slmgr.vbs /ipk %ProductKey%
echo 第三步、联网激活
cscript /nologo %windir%\System32\slmgr.vbs /ato
echo ------ 激活 %Name% 执行完毕 ------
title 激活 %Name% 完毕
goto :eof
rem ----------------------------------------------



rem ----------------------------------------------
:Office15
set Name=Office 2013 VL
set OfficeName=Office15
set ProductKey=YC7DK-G2NP3-2QQC3-J6H88-GVGXT
call :atoffice
goto :eof
exit


:Office14
set Name=Office 2010 VL
set OfficeName=Office14
set ProductKey=YC7DK-G2NP3-2QQC3-J6H88-GVGXT
call :atoffice
goto :eof
exit


:atoffice
rem 激活Office
title 激活 %Name%
echo.
echo ------ 激活 %Name% ------
echo.
rem 手动激活需要单独获取一次
if "%OfficePath%"=="" (
FOR /F "tokens=1,2,* delims= " %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe" /v "Path" 2^>^>%LogFileName%') do set OfficePath=%%k
FOR /F "tokens=1-5 delims=\\" %%l in ("!OfficePath!") do set OfficeNameFromReg=%%o
)
rem 如果获取之后还是为空,说明没有安装,仅针对手动
if "%OfficePath%"=="" (
echo 系统检测到您没有安装 %Name% 产品
goto :eof
)
rem 如果版本号不匹配,说明用户选择错误,仅针对手动
if not "%OfficeName%"=="%OfficeNameFromReg%" (
echo 您选择的版本:%OfficeName%
echo 您安装的版本:%OfficeNameFromReg%
echo 系统检测到您选择的和您安装的版本不符,请返回重新选择
goto :eof
)
set osppFile="%OfficePath%ospp.vbs"
echo 第一步、设置密钥管理服务计算机名称
ipconfig /flushdns >nul 2>nul
cscript /nologo %osppFile% /remhst >nul 2>>%LogFileName%
cscript /nologo %osppFile% /sethst:%KMSServer% >nul 2>>%LogFileName%
echo 密钥管理服务计算机名称成功地设置为 %KMSServer%。
echo.
echo 第二步、安装产品密钥
cscript /nologo %osppFile% /inpkey:%ProductKey% | find /i "successful" >nul 2>>%LogFileName% && echo 成功地安装了产品密钥 %ProductKey%。 || echo 产品序列号无效或设置失败。
echo.
echo 第三步、联网激活
cscript /nologo %osppFile% /act | find /i /v "successful" >nul 2>>%LogFileName% && echo 成功地激活了产品。 || echo 产品激活失败。
echo.
echo ------ 激活 %Name% 执行完毕 ------
title 激活 %Name% 完毕
goto :eof
rem ----------------------------------------------


rem ----------------------------------------------
:list
title 可激活的操作系统和Office列表
echo Office
echo Office 2013                                       YC7DK-G2NP3-2QQC3-J6H88-GVGXT
echo Office 2010                                       YC7DK-G2NP3-2QQC3-J6H88-GVGXT
echo.
echo Windows 8.1 and Windows Server 2012 R2
echo Windows 8.1 Professional                          GCRJD-8NW9H-F2CDX-CCM8D-9D6T9
echo Windows 8.1 Professional N (暂不支持)             HMCNV-VVBFX-7HMBH-CTY9B-B4FXY
echo Windows 8.1 Enterprise                            MHF9N-XY6XB-WVXMC-BTDCT-MKKG7
echo Windows 8.1 Enterprise N (暂不支持)               TT4HM-HN7YT-62K67-RGRQJ-JFFXW
echo Windows Server 2012 R2 Server Standard            D2N9P-3P6X9-2R39C-7RTCD-MDVJX
echo Windows Server 2012 R2 Datacenter                 W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9
echo Windows Server 2012 R2 Essentials (暂不支持)      KNC87-3J2TX-XB4WP-VCPJV-M4FWM
echo.
echo Windows 8 and Windows Server 2012
echo Windows 8 Professional                            NG4HW-VH26C-733KW-K6F98-J8CK4
echo Windows 8 Professional N (暂不支持)               XCVCF-2NXM9-723PB-MHCB7-2RYQQ
echo Windows 8 Enterprise                              32JNW-9KQ84-P47T8-D8GGY-CWCK7
echo Windows 8 Enterprise N (暂不支持)                 JMNMF-RHW7P-DMY6X-RF3DR-X2BQT
echo Windows Server 2012                               BN3D2-R7TKB-3YPBD-8DRP2-27GG4
echo Windows Server 2012 N (暂不支持)                  8N2M2-HWPGY-7PGT9-HGDD8-GVGGY
echo Windows Server 2012 Single Language (暂不支持)    2WN2H-YGCQR-KFX6K-CD6TF-84YXQ
echo Windows Server 2012 Country Specific (暂不支持)   4K36P-JN4VD-GDC6V-KDT89-DYFKP
echo Windows Server 2012 Server Standard               XC9B7-NBPP2-83J2H-RHMBY-92BT4
echo Windows Server 2012 MultiPoint Standard (暂不支持)HM7DN-YVMH3-46JC3-XYTG7-CYQJJ
echo Windows Server 2012 MultiPoint Premium (暂不支持) XNH6W-2V9GX-RGJ4K-Y8X6F-QGJ2G
echo Windows Server 2012 Datacenter                    48HP8-DN98B-MYWDG-T2DCC-8W83P
echo.
echo Windows 7 and Windows Server 2008 R2
echo Windows 7 Professional                            FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4
echo Windows 7 Professional N (暂不支持)               MRPKT-YTG23-K7D7T-X2JMM-QY7MG
echo Windows 7 Professional E (暂不支持)               W82YF-2Q76Y-63HXB-FGJG9-GF7QX
echo Windows 7 Enterprise (暂不支持)                   33PXH-7Y6KF-2VJC9-XBBR8-HVTHH
echo Windows 7 Enterprise N (暂不支持)                 YDRBP-3D83W-TY26F-D46B2-XCKRJ
echo Windows 7 Enterprise E (暂不支持)                 C29WB-22CC8-VJ326-GHFJW-H9DH4
echo Windows Server 2008 R2 Web (暂不支持)             6TPJF-RBVHG-WBW2R-86QPH-6RTM4
echo Windows Server 2008 R2 HPC edition (暂不支持)     TT8MH-CG224-D3D7Q-498W2-9QCTX
echo Windows Server 2008 R2 Standard (暂不支持)        YC6KT-GKW9T-YTKYR-T4X34-R7VHC
echo Windows Server 2008 R2 Enterprise                 489J6-VHDMP-X63PK-3K798-CPX3Y
echo Windows Server 2008 R2 Datacenter (暂不支持)      74YFP-3QFB3-KQT8W-PMXWJ-7M648
echo Windows Server 2008 R2 for Itanium-based Systems (暂不支持)GT63C-RJFQ3-4GMB6-BRFB9-CB83V
echo.
echo Windows Vista and Windows Server 2008
echo Windows Vista Business (暂不支持)                 YFKBB-PQJJV-G996G-VWGXY-2V3X8
echo Windows Vista Business N (暂不支持)               HMBQG-8H2RH-C77VX-27R82-VMQBT
echo Windows Vista Enterprise (暂不支持)               VKK3X-68KWM-X2YGT-QR4M6-4BWMV
echo Windows Vista Enterprise N (暂不支持)             VTC42-BM838-43QHV-84HX6-XJXKV
echo Windows Web Server 2008 (暂不支持)                WYR28-R7TFJ-3X2YQ-YCY4H-M249D
echo Windows Server 2008 Standard (暂不支持)           TM24T-X9RMF-VWXK6-X8JC9-BFGM2
echo Windows Server 2008 Standard without Hyper-V (暂不支持)W7VD6-7JFBR-RX26B-YKQ3Y-6FFFJ
echo Windows Server 2008 Enterprise (暂不支持)         YQGMW-MPWTJ-34KDK-48M3W-X4Q6V
echo Windows Server 2008 Enterprise without Hyper-V (暂不支持)39BXF-X8Q23-P2WWT-38T2F-G3FPG
echo Windows Server 2008 HPC (暂不支持)                RCTX3-KWVHP-BR6TB-RB6DM-6X7HP
echo Windows Server 2008 Datacenter (暂不支持)         7M67G-PC374-GR742-YH8V4-TCBY3
echo Windows Server 2008 Datacenter without Hyper-V (暂不支持)22XQ2-VRXRG-P8D42-K34TD-G3QQC
echo Windows Server 2008 for Itanium-Based Systems (暂不支持)4DWFP-JF3DJ-B7DTH-78FJB-PDRHK

FOR /F "tokens=1,2,* delims= " %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName" 2^>^>%LogFileName%') do echo 您的系统是:%%k

goto :eof
rem ----------------------------------------------



rem ----------------------------------------------
:rdp
@echo off
:: Code by xy 2013-01-10, 11,03-26

title 开启远程桌面 Code by xy 2013-01-10, 11,03-26

echo ------ 开启远程桌面 ------
echo 说明:
echo 1.本脚本能够开启远程桌面功能、设定远程桌面端口、
echo   添加防火墙规则并禁用3389端口等的一系列功能,
echo   并且不需要重新启动系统即可生效。
echo 2.本脚本在 Windows Server 2012 DataCenter 简体中文版上测试成功。
echo   理论上也支持 WS2012、WS2008R2、WS2008、Win8、Win7、Vista 全系列64位、32位版本。
echo   对于 WS2003、WinXP 等不支持高级防火墙的需要修改本脚本中防火墙相关命令。
echo   对于非简体中文版本需要修改本脚本中防火墙相关命令。
echo 3.请右键以管理员身份运行,如果没有请关闭本窗口,重新运行。
echo 4.执行完毕之后会有提示,请耐心等待。
echo.
echo ------ 执行 ------
echo.

echo 备份相关注册表项到 3389.reg.bak :
reg export "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" 3389.reg.%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%.bak
echo.

set /p port=请输入端口:
echo.

echo 删除原端口防火墙规则...
rem set /a n=0xff 转换16进制到10进制并赋予变量n
for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber^|find /i "PortNumber"
') do set /a pn=%%a
if not %pn%==3389 (
netsh advfirewall firewall delete rule name=all protocol=tcp localport=%pn%
netsh advfirewall firewall delete rule name=all protocol=udp localport=%pn%
)
for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber^|find /i "PortNumber"
') do set /a pn=%%a
if not %pn%==3389 (
netsh advfirewall firewall delete rule name=all protocol=tcp localport=%pn%
netsh advfirewall firewall delete rule name=all protocol=udp localport=%pn%
)
echo.

echo 添加新端口防火墙规则...
netsh advfirewall firewall add rule name="%port% - rdp (TCP-In)" dir=in action=allow protocol=TCP localport=%port%
netsh advfirewall firewall add rule name="%port% - rdp (UDP-In)" dir=in action=allow protocol=UDP localport=%port%
echo.

echo 禁用3389端口...
netsh advfirewall firewall set rule group="远程桌面" new enable=no
echo.

echo 正在修改端口...
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t REG_DWORD /d %port% /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d %port% /f
echo.

echo 正在启用远程桌面功能,稍后会断开连接...
echo 请稍后使用新端口手动连接...
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
echo.

echo 正在重启远程桌面服务...
net stop "Remote Desktop Services" /y
net start "Remote Desktop Services"
echo.

echo 执行完毕
pause >nul
goto :eof
exit


:3389
@echo off
:: Code by xy 2013-01-10, 11

title 开启远程桌面 Code by xy 2013-01-10, 11

echo ------ 开启远程桌面 ------
echo 注意:
echo 1.请先添加防火墙规则!!!
echo 2.切记第一条!!!
echo 3.仔细看下面的说明!!!
echo 说明:
echo 1.本脚本能够开启远程桌面功能、设定远程桌面端口,但需要重启才能生效。
echo 2.本脚本在 Windows Server 2012 DataCenter 简体中文版上测试成功。
echo   理论上也支持 WS12、WS08、WS03、W8、W7、Vista、XP 全系列64位、32位版本。
echo 3.执行完毕之后会有提示,请耐心等待。
echo.
echo ------ 执行 ------
echo.
set /p port=请输入端口:
echo.
echo 正在修改端口...
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t REG_DWORD /d %port% /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d %port% /f
echo.
echo 正在启用远程桌面功能...
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
echo.
echo 执行完毕
goto :eof
exit

:AutoLogonAndLockWorkStation
@echo off
:: Code by xy 2013-09-13

title 设定开机自动登陆并锁定系统 Code by xy 2013-09-13

start control userpasswords2

ver | findstr "5\.[0-9]\.[0-9][0-9]*" > nul && goto winnt5x
ver | findstr "6\.[0-9]\.[0-9][0-9]*" > nul && goto winnt6x

:winnt5x
echo rundll32.exe user32.dll,LockWorkStation > "%USERPROFILE%\「开始」菜单\程序\启动\LockWorkStation.bat"
explorer.exe "%USERPROFILE%\「开始」菜单\程序\启动\"
echo 执行完毕
goto :eof
exit

:winnt6x
echo rundll32.exe user32.dll,LockWorkStation > "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\LockWorkStation.bat"
explorer.exe "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
echo 执行完毕
goto :eof
exit

:close_service
@echo off
:: Code by xy 2013-04-12

title 关闭服务使系统更安全 Code by xy 2013-04-12

sc stop Browser
sc stop Spooler
sc stop RemoteRegistry
sc stop LanmanServer
sc stop ShellHWDetection
sc stop Schedule
sc stop lmhosts
sc stop LanmanWorkstation

sc config Browser start=disabled
sc config Spooler start=disabled
sc config RemoteRegistry start=disabled
sc config LanmanServer start=disabled
sc config ShellHWDetection start=disabled
sc config Schedule start=disabled
sc config lmhosts start=disabled
sc config LanmanWorkstation start=disabled

echo 执行完毕
goto :eof
exit

:macfetch
@echo off
:: Code by xy 2013-09-23

title 获取网卡MAC地址 Code by xy 2013-09-23

:op
cls
echo 1.获取MAC地址并输出到指定文件
echo 2.整理MAC地址并复制到剪贴板
echo 0.返回
echo.
set op=
set /p op=    输入选项后按回车键:
if "%op%"=="1" goto FETCHMAC
if "%op%"=="2" goto CLEARMAC
if "%op%"=="0" goto tools
cls
GOTO op

:FETCHMAC
echo.
set /p name=Your name: 
ipconfig /all > mac_%name%.txt
echo MAC address has been saved in mac_%name%.txt
pause
cls
GOTO op

:CLEARMAC
echo.
echo 输入0返回
echo.
set /p name=Your MAC: 
if %name%==0 goto :op
set name=%name:-=%
echo Clean MAC: %name%
mshta vbscript:clipboarddata.setdata("text","%name%")(close)
GOTO CLEARMAC
rem ----------------------------------------------

:checkver
echo.
FOR /F "tokens=1,2,* delims= " %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName" 2^>^>%LogFileName%') do set OSNameFromReg=%%k
echo 您的 Windows 版本为:%OSNameFromReg% (OSNameFromReg)
echo 您的 Windows 版本为:%OSNameFromReg% (OSNameFromReg) >> %LogFileName%
mshta vbscript:clipboarddata.setdata("text","我的 Windows 版本为:%OSNameFromReg% (OSNameFromReg)")(close)
echo Windows 版本名称已复制到剪贴板,请粘贴到群里或评论区报告给作者,谢谢!
goto :eof
exit