Win Server 运维命令集合
开启 ping
## 开启 ping
netsh firewall set icmpsetting 8
## 禁用 ping
netsh firewall set icmpsetting 8 disable
## Win server 2019
netsh advfirewall firewall set icmpsetting 8
或者 直接操作防火墙
开启远程端口
新建 xxx.cmd 文件,内容如下:
@echo off
color 0a
title 修改Windows 2003/2008远程桌面服务端口号
echo *******************************************************************
echo * 请输入您要更改的远程桌面端口号,范围:1024-65535,不能与其他端口冲突*
echo *******************************************************************
echo.
set /p port=请输入端口:
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
netsh firewall set opmode mode = enable
netsh firewall set portopening all 80 web enable
netsh firewall set portopening all 3389 remote-pre enable
netsh firewall set portopening all %port% remote enable
echo.
echo *******************************
echo * 重新启动远程桌面*
echo *******************************
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 0 /f
echo.
echo 下面开始重新启动电脑以生效,请选择启动方式:
echo 选择1手动重新启动
echo 选择2自动重新启动
set /p select=请您选择1,2:
if "%select%"=="1" goto A
if "%select%"=="2" goto B
pause
exit
:A
echo 退出,请手动重新启动电脑
pause
exit
:B
shutdown -r -t 1
pause
exit
定,精,简,俭