>

echo ----正在备份注册表 请稍后....----,+文件来更

- 编辑:澳门博发娱乐官网 -

echo ----正在备份注册表 请稍后....----,+文件来更

一、需要重启

复制代码 代码如下:

本人负责的部门有上百台机器,重装完后需要恢复原有配置,我曾使用过很多方法:
1:手工更改,这条就不要说了
2:使用netsh dump +文件和 netsh -f +文件来更改,但是整个盘都格式化就没用.
3:使用专用的更改ip地址的小程序,但还是需要手工来指定IP

复制代码 代码如下:

cls
 @color 0A
 @mode con cols=80 lines=32
 @title ★修改默认3389端口★
 @echo off
 echo =====================================================
 echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
 echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
 echo ※                               修改3389.bat v1.0                            ※
 echo ※                                 create by jim                              ※
 echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
 echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
 echo 时间:%date%   %time%
 echo =======================================================
 echo 用途:通过修改注册表,修改默认3389端口
echo =======================================================
 goto :3389-1
 :3389-1
 ::***********************************************************
 ::导出3389端口默认注册表
reg export "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server"  c:3389.reg
 goto :3389-2
 :3389-2
 set port1=53389
reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /t REG_DWORD /v portnumber /d %port1% /f
 set port2=53389
reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Serverwdsrdpwdtdstcp" /t REG_DWORD /v portnumber /d %port1% /f
 if %port1%==%port2% (echo 修改成功!!!) else (echo 两次输入不一致,请重新输入。&goto 3389-2)
 goto :QUIT
 :QUIT
netsh firewall set portopening tcp 53389 mstsc-53389 enable
net stop TermService
net start TermService
 echo ________________________________________________________
 echo.
 echo ________________________________________________________
 echo            [Press any key to quit]
 echo ________________________________________________________
 echo.
 pause >nul
 exit

@echo off
set /p pcnanme=请输入计算机的名字:
reg add HKEY_LOCAL_MACHINESYSTEMControlSet001ControlComputerNameComputerName /v ComputerName /t REG_SZ /d %pcnanme% /f
eixt

@echo off
echo 骏龙包装计算机名称、计算机描述、工作组修改批处理程序
Echo
pause
cls
:set/p id=请输入本机网段号:
:set/p ip=请输入本机IP地址:
:netsh interface ip set address name="本地连接" source=static addr=192.168.%id%.%ip% mask=255.255.255.0
set /p name=请输您的主机出厂S/N编号:
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetControlComputerNameActiveComputerName" /v ComputerName /t reg_sz /d %name% /f
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetServicesTcpipParameters" /v "NV Hostname" /t reg_sz /d %name% /f
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetServicesTcpipParameters" /v Hostname /t reg_sz /d %name% /f
SET work=骏龙
wmic computersystem where Name="%NAME%" call JoinDomainOrWorkgroup Name="%work%"
set /p describe=请输入您的计算机描述(公司规定必须是使用者姓名):
reg add "HKEY_LOCAL_MACHINESystemCurrentControlSetServiceslanmanserverParameters" /v srvcomment /t reg_sz /d %describe% /f

最后,我想到如下办法:
1:首先实现:netsh interface ip 来更改IP
2:使用wmic computersystem 修改工作组
3:使用reg add 来更改机器名
4:因为修改机器名后要重启才生效,于是使用:reboot.inf 来重启
5:后来增加了新机器名和ip的配置,使用机器的序列号(联想机:wmic bios get SerialNumber)来做机器名,ip地址最后1位使用随机
因为可以通过 wmic来读取序列号,那么我们可以用来登记本机的网络配置时,就方便多了.
6:最后将自己整理的IP地址等对应表放到了bat中,避免bat调用其他文件.
7:实现上面功能后,我就可以将该bat文件封装到gho文件里面,恢复重启完后就可以自动设置,我不要做其他操作,用户就可以使用.如果有必要,你可以加上执行完后自动删除本身.

@echo off
echo ----------------------------------
echo ----正在备份注册表 请稍后....----
echo ----------------------------------
  reg export "HKEY_LOCAL_MACHINE" C:/reg_backup.reg
echo ----------------------
echo ----注册表备份完成----
echo ----------------------
  ping 127.0.0.1 -n 3 >nul
echo -----------------------------------
echo ----安全配置正在改写 请稍候...----
echo -----------------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------
echo ----正在禁用空连接----
echo ----------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa /v restrictanonymous /t reg_dword /d 1 /f
echo --------------------------
echo ----禁用空连接设置完毕----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------
echo ----正在删除默认共享----
echo ------------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceslanmanserverparameters /v AutoShareServer /t reg_dword /d 0 /f
echo ----------------------------
echo ----删除默认共享设置完毕----
echo ----------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------
echo ----正在修改TTL值请稍后...----
echo ------------------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v DefaultTTL /t reg_dword /d 53 /f
echo -------------------
echo ----TTL修改完毕----
echo -------------------
  @ping 127.0.0.1 -n 3 >nul
echo -----------------------
echo ----防止syn洪水攻击----
echo -----------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v SynAttackProtect /t reg_dword /d 2 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v EnablePMTUDiscovery /t reg_dword /d 0 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v NoNameReleaseOnDemand /t reg_dword /d 1 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v EnableDeadGWDetect /t reg_dword /d 0 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v KeepAliveTime /t reg_dword /d 300000 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v PerformRouterDiscovery /t reg_dword /d 0 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v EnableICMPRedirects /t reg_dword /d 0 /f
echo -------------------------------
echo ----防止syn洪水攻击设置完毕----
echo -------------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------
echo ------------------------------
echo ---- 系统服务修改 ----
echo ------------------------------
echo ------------------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------
echo ----修改3389端口----
echo --------------------
  reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWds dpwdTdstcp" /v PortNumber /t reg_dword /d 44454 /f
  reg add "HKEY_LOCAL_MACHINESYSTEMCurrentContro1SetControlTenninal ServerWinStationsRDPTcp" /v PortNumber /t reg_dword /d 44454 /f
echo --------------------
echo ----修改PORT完毕----
echo --------------------
  @ping 127.0.0.1 -n 3 >nul
echo -------------------------------------
echo ----正在开启系统防火墙 请稍后....----
echo -------------------------------------
  sc config sharedaccess start= auto & net start sharedaccess
echo ------------------------
echo ----系统防火墙已开启----
echo ------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------
echo ----正在关闭共享打印服务----
echo ----------------------------
  @sc config Spooler start= disabled
  sc config LanmanServer start= disabled
  sc config LmHosts start= disabled
echo --------------------------
echo ----已关闭共享打印服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------
echo ----正在关闭远程协助服务----
echo ----------------------------
  @sc config RDSessMgr start= disabled
echo --------------------------
echo ----已关闭远程协助服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------
echo ----正在关闭远程注册表服务----
echo ------------------------------
  @sc config RemoteRegistry start= disabled
echo ----------------------------
echo ----已关闭远程注册表服务----
echo ----------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------
echo ----关闭自动硬件播放通知----
echo ----------------------------
  sc config ShellHWDetection start= disabled
echo -----------------------
echo ----自动播放通知关闭---
echo -----------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------------------
echo ----正在关闭替换凭据下的启动进程服务----
echo ----------------------------------------
  sc config seclogon start= disabled
echo --------------------------
echo ----已关闭启动进程服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------------
echo ----IEEE 802.11 适配器的自动配置----
echo ------------------------------------
  sc config WZCSVC start= disabled
echo ------------------
echo ----已关闭IEEE----
echo ------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------------
echo ----客户端跟踪服务关闭----
echo --------------------------
  sc config TrkSvr start= disabled
  sc config MSDTC start= disabled
echo ----------------------------
echo ----已关闭客户端跟踪服务----
echo ----------------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------
echo ----帮助中心关闭----
echo --------------------
  sc config helpsvc start= disabled
echo --------------------------
echo ----已关闭帮助中心服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------------------
echo --------------------------------
echo ---- 系统权限加固 ----
echo --------------------------------
echo --------------------------------
echo -------------------------------------------------------
echo ----C盘(系统盘) (administrators,system完全控制权限)----
echo -------------------------------------------------------
  cacls C: /t /c /g administrators:F system:F
echo -------------------------------------------
echo ----Common Files (everyone用户只读权限)----
echo -------------------------------------------
  Cacls "C:Program FilesCommon Files" /t /e /c /g everyone:R
echo -------------------------------------------------------------
echo ----IIS Temporary Compressed Files (everyone用户更改权限)----
echo -------------------------------------------------------------
  Cacls "C:WINDOWSIIS Temporary Compressed Files" /t /e /c /g everyone:C
echo --------------------------------------------
echo ----Microsoft.Net (everyone用户只读权限)----
echo --------------------------------------------
  Cacls C:WINDOWSMicrosoft.Net /t /e /c /g everyone:R
echo ------------------------------------------------------
echo ----Temporary ASP.NET Files (everyone用户更改权限)----
echo ------------------------------------------------------
  Cacls "C:WINDOWSMicrosoft.NETFrameworkv1.1.4322Temporary ASP.NET Files" /t /e /c /g everyone:C
echo ------------------------------------------------------
echo ----Temporary ASP.NET Files (everyone用户更改权限)----
echo ------------------------------------------------------
  Cacls "C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files" /t /e /c /g everyone:C
echo -------------------------------------------
echo ----Registration (everyone用户读取权限)----
echo -------------------------------------------
  Cacls C:WINDOWSRegistration /t /e /c /g everyone:R
echo -----------------------------------
echo ----Temp (everyone用户更改权限)----
echo -----------------------------------
  Cacls C:WINDOWSTemp /t /e /c /g everyone:C
echo -------------------

需要重启电脑才能生效

net config server /SRVCOMMENT:"%describe%"
pause

整个代码如下:(欢迎大家继续优化和整理)

 @echo off
echo ----------------------------------
echo ----正在备份注册表 请稍后....----
echo ----------------------------------
  reg export "HKEY_LOCAL_MACHINE" C:/reg_backup.reg
echo ----------------------
echo ----注册表备份完成----
echo ----------------------
  ping 127.0.0.1 -n 3 >nul
echo -----------------------------------
echo ----安全配置正在改写 请稍候...----
echo -----------------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------
echo ----正在禁用空连接----
echo ----------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa /v restrictanonymous /t reg_dword /d 1 /f
echo --------------------------
echo ----禁用空连接设置完毕----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------
echo ----正在删除默认共享----
echo ------------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceslanmanserverparameters /v AutoShareServer /t reg_dword /d 0 /f
echo ----------------------------
echo ----删除默认共享设置完毕----
echo ----------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------
echo ----正在修改TTL值请稍后...----
echo ------------------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v DefaultTTL /t reg_dword /d 53 /f
echo -------------------
echo ----TTL修改完毕----
echo -------------------
  @ping 127.0.0.1 -n 3 >nul
echo -----------------------
echo ----防止syn洪水攻击----
echo -----------------------
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v SynAttackProtect /t reg_dword /d 2 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v EnablePMTUDiscovery /t reg_dword /d 0 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v NoNameReleaseOnDemand /t reg_dword /d 1 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v EnableDeadGWDetect /t reg_dword /d 0 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v KeepAliveTime /t reg_dword /d 300000 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v PerformRouterDiscovery /t reg_dword /d 0 /f
  reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters /v EnableICMPRedirects /t reg_dword /d 0 /f
echo -------------------------------
echo ----防止syn洪水攻击设置完毕----
echo -------------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------
echo ------------------------------
echo ---- 系统服务修改 ----
echo ------------------------------
echo ------------------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------
echo ----修改3389端口----
echo --------------------
  reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWds dpwdTdstcp" /v PortNumber /t reg_dword /d 44454 /f
  reg add "HKEY_LOCAL_MACHINESYSTEMCurrentContro1SetControlTenninal ServerWinStationsRDPTcp" /v PortNumber /t reg_dword /d 44454 /f
echo --------------------
echo ----修改PORT完毕----
echo --------------------
  @ping 127.0.0.1 -n 3 >nul
echo -------------------------------------
echo ----正在开启系统防火墙 请稍后....----
echo -------------------------------------
  sc config sharedaccess start= auto & net start sharedaccess
echo ------------------------
echo ----系统防火墙已开启----
echo ------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------
echo ----正在关闭共享打印服务----
echo ----------------------------
  @sc config Spooler start= disabled
  sc config LanmanServer start= disabled
  sc config LmHosts start= disabled
echo --------------------------
echo ----已关闭共享打印服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------
echo ----正在关闭远程协助服务----
echo ----------------------------
  @sc config RDSessMgr start= disabled
echo --------------------------
echo ----已关闭远程协助服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------
echo ----正在关闭远程注册表服务----
echo ------------------------------
  @sc config RemoteRegistry start= disabled
echo ----------------------------
echo ----已关闭远程注册表服务----
echo ----------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------
echo ----关闭自动硬件播放通知----
echo ----------------------------
  sc config ShellHWDetection start= disabled
echo -----------------------
echo ----自动播放通知关闭---
echo -----------------------
  @ping 127.0.0.1 -n 3 >nul
echo ----------------------------------------
echo ----正在关闭替换凭据下的启动进程服务----
echo ----------------------------------------
  sc config seclogon start= disabled
echo --------------------------
echo ----已关闭启动进程服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo ------------------------------------
echo ----IEEE 802.11 适配器的自动配置----
echo ------------------------------------
  sc config WZCSVC start= disabled
echo ------------------
echo ----已关闭IEEE----
echo ------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------------
echo ----客户端跟踪服务关闭----
echo --------------------------
  sc config TrkSvr start= disabled
  sc config MSDTC start= disabled
echo ----------------------------
echo ----已关闭客户端跟踪服务----
echo ----------------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------
echo ----帮助中心关闭----
echo --------------------
  sc config helpsvc start= disabled
echo --------------------------
echo ----已关闭帮助中心服务----
echo --------------------------
  @ping 127.0.0.1 -n 3 >nul
echo --------------------------------
echo --------------------------------
echo ---- 系统权限加固 ----
echo --------------------------------
echo --------------------------------
echo -------------------------------------------------------
echo ----C盘(系统盘) (administrators,system完全控制权限)----
echo -------------------------------------------------------
  cacls C: /t /c /g administrators:F system:F
echo -------------------------------------------
echo ----Common Files (everyone用户只读权限)----
echo -------------------------------------------
  Cacls "C:Program FilesCommon Files" /t /e /c /g everyone:R
echo -------------------------------------------------------------
echo ----IIS Temporary Compressed Files (everyone用户更改权限)----
echo -------------------------------------------------------------
  Cacls "C:WINDOWSIIS Temporary Compressed Files" /t /e /c /g everyone:C
echo --------------------------------------------
echo ----Microsoft.Net (everyone用户只读权限)----
echo --------------------------------------------
  Cacls C:WINDOWSMicrosoft.Net /t /e /c /g everyone:R
echo ------------------------------------------------------
echo ----Temporary ASP.NET Files (everyone用户更改权限)----
echo ------------------------------------------------------
  Cacls "C:WINDOWSMicrosoft.NETFrameworkv1.1.4322Temporary ASP.NET Files" /t /e /c /g everyone:C
echo ------------------------------------------------------
echo ----Temporary ASP.NET Files (everyone用户更改权限)----
echo ------------------------------------------------------
  Cacls "C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files" /t /e /c /g everyone:C
echo -------------------------------------------
echo ----Registration (everyone用户读取权限)----
echo -------------------------------------------
  Cacls C:WINDOWSRegistration /t /e /c /g everyone:R
echo -----------------------------------
echo ----Temp (everyone用户更改权限)----
echo -----------------------------------
  Cacls C:WINDOWSTemp /t /e /c /g everyone:C
echo -------------------
echo ----assembly (everyone用户读取权限)----
echo ---------------------------------------
  Cacls C:WINDOWSassembly /t /e /c /g everyone:R
echo -------------------------------------
echo ----WinSxS (everyone用户读取权限)----
echo -------------------------------------
  Cacls C:WINDOWSWinSxS /t /e /c /g everyone:R
echo ------------------------------------
echo ----Fonts (everyone用户读取权限)----
echo ------------------------------------
  Cacls C:WINDOWSFonts /t /e /c /g everyone:R
echo ---------------------------------------
echo ----System32 (everyone用户读取权限)----
echo ---------------------------------------
  Cacls C:WINDOWSSystem32 /t /e /c /g everyone:R
echo ------------------------------------------
echo ----msdtc (networkservice用户更改权限)----
echo ------------------------------------------
  Cacls C:windowssystem32msdtc /t /e /c /g networkservice:C
echo -----------------------------------------------------
echo ----ASP Compiled Templates (everyone用户更改权限)----
echo -----------------------------------------------------
  Cacls "C:WINDOWSsystem32inetsrvASP Compiled Templates" /t /e /c /g everyone:C
echo ------------------------------------
echo ----*.exe (去除everyone用户权限)----
echo ------------------------------------
  Cacls C:WINDOWSSystem32*.exe /e /c /r everyone
echo ------------------------------------
echo ----cmd.exe (去除system用户权限)----
echo ------------------------------------
  Cacls C:WINDOWSSystem32cmd.exe /e /c /r system
echo ------------------------------------
echo ----net.exe (去除system用户权限)----
echo ------------------------------------
  Cacls C:WINDOWSSystem32 et.exe /e /c /r system
echo -------------------------------------
echo ----net1.exe (去除system用户权限)----
echo -------------------------------------
  Cacls C:WINDOWSSystem32 et1.exe /e /c /r system
echo ----------------------------------------
echo ----msdtc.exe (everyone用户读取权限)----
echo ----------------------------------------
  Cacls C:WINDOWSSystem32msdtc.exe /e /c /g everyone:R
echo ------------------------------------------
echo ----dllhost.exe (everyone用户读取权限)----
echo ------------------------------------------
  Cacls C:WINDOWSSystem32dllhost.exe /e /c /g everyone:R
echo ------------------------------------------
echo ----svchost.exe (everyone用户读取权限)----
echo ------------------------------------------
  Cacls C:WINDOWSSystem32svchost.exe /e /c /g everyone:R
echo --------------------
echo --------------------
echo ----系统加固完毕----
echo --------------------
echo --------------------
  @ping 127.0.0.1 -n 3 >nul
echo -----------------------------
echo ----安全设置完毕 欢迎使用----
echo -----------------------------
echo ------------------
echo ----重启服务器----
echo ------------------
  @ping 127.0.0.1
  shutdown -r
  @pause

本文由胜博发-操作发布,转载请注明来源:echo ----正在备份注册表 请稍后....----,+文件来更