快捷修改用户密码、主机名、获取电脑配置、关闭危险端口和共享服务


@ECHO OFF & title PC config 
mode con cols=46 lines=20
@ECHO OFF 
color 0a
@ECHO OFF 

:MENU
ECHO.
echo                 功能菜单选项
echo     =====================================
echo    ^|                                    ^|
echo    ^|  1:修改当前用户密码  2:修改主机名称   ^|
echo    ^|                                    ^|
echo    ^|  3:获取电脑配置信息  4:关闭危险端口   ^|
echo    ^|                                    ^| 
echo    ^|  5:关闭共享服务      6:exit         ^|
echo    ^|                                    ^|
echo     =====================================
echo.

echo.

set /p user_input=  请输入数字:

if %user_input% equ 1 goto cmd1

if %user_input% equ 2 goto cmd2

if %user_input% equ 3 goto cmd3

if %user_input% equ 4 goto cmd4

if %user_input% equ 5 goto cmd5

if %user_input% equ 6 exit

:cmd1
@echo off
echo.    [0]返回
@echo  当前账户:%username%
set /p pass=  请输入新密码:
if "pass" equ 0 goto menu
net user %username% %pass%
pause
goto MENU

:cmd2
@Echo off
Color 0A
title    快捷更改计算机名
:A
cls
echo.
echo.    [0]返回 
echo.
echo.   不用重启电脑直接生效^_^ 
echo.
echo.
set /p pc=  [输入计算机名] # 
If "%pc%"=="" goto A
If "%pc%"=="0" goto menu 
set computername=%pc%
:: PC name
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d "%computername%" /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t reg_sz /d "%computername%" /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d "%computername%" /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d "%computername%" /f

goto menu

:cmd3

@echo off & title 获取本机简要配置信息 
 
::设置信息保存路径
set Log=C:\%USERNAME%-%COMPUTERNAME%简要配置信息.txt
 
echo WScript.Echo Wscript.Arguments(0) / (1024 * 1024 * 1024)>Calculation.vbs
echo 正在获取信息中 ...
(for /f "tokens=2 delims==" %%a in ('wmic csproduct get Name /value ^| findstr /i "Name"') do echo 电脑型号:%%~a
for /f "tokens=2 delims==" %%a in ('wmic csproduct get Vendor /value ^| findstr /i "Vendor"') do echo 制 造 商:%%~a
for /f "tokens=2 delims==" %%a in ('wmic csproduct get IdentifyingNumber /value ^| findstr /i "IdentifyingNumber"') do echo SN序列号:%%~a
echo 登 录 名:%USERNAME%
echo 计算机名:%COMPUTERNAME%
for /f "tokens=2 delims==" %%a in ('wmic cpu get Name /value ^| findstr /i "Name"') do echo 处 理 器:%%~a
for /f "tokens=2 delims==" %%a in ('wmic memorychip get Capacity /value ^| findstr /i "Capacity"') do (
    for /f "tokens=1 delims=." %%b in ('cscript /nologo Calculation.vbs "%%~a"') do set /a m+=%%~b
)
call echo 内存容量:%%m%% GB
for /f "tokens=2 delims==" %%a in ('wmic DiskDrive get Size /value ^| findstr /i "Size"') do  (
    for /f "tokens=1 delims=." %%b in ('cscript /nologo Calculation.vbs "%%~a"') do set /a d+=%%~b
)
call echo 硬盘容量:%%d%% GB
for /f "tokens=2 delims==" %%a in ('wmic nic where "netconnectionid!=NULL" get macaddress /value ^| findstr /i "MACAddress"') do echo MAC 地址:%%~a)>"%Log%"
del Calculation.vbs
echo 信息获取,并保存。
goto menu

:cmd4
 @echo off
 color 0a 
 title 您正在使用一键屏蔽危险端口和服务
 echo 您正在使用一键屏蔽危险端口和服务
 echo "正在帮您关闭这些危险端口,请稍等"
 echo “正在开启Windows防火墙服务
 net start MpsSvc
 echo ”正在帮您开启Windows防火墙自启动
 sc config MpsSvc start= auto
 echo ”正在启用防火墙
 netsh advfirewall set allprofiles state on
 echo "正在帮您屏蔽端口...."
 echo. 
 echo. 
 echo. 
 echo 正在屏蔽135端口 请稍候
 netsh advfirewall firewall delete rule name = "Disable port 135 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 135 - TCP" dir = in action = block protocol = TCP localport = 135
 echo. 
 netsh advfirewall firewall delete rule name = "Disable port 135 - UDP"
 netsh advfirewall firewall add rule name = "Disable port 135 - UDP" dir = in action = block protocol = UDP localport = 135
 echo. 
 echo 正在屏蔽137端口 请稍候
 netsh advfirewall firewall delete rule name = "Disable port 137 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 137 - TCP" dir = in action = block protocol = TCP localport = 137
 echo. 
 netsh advfirewall firewall delete rule name = "Disable port 137 - UDP"
 netsh advfirewall firewall add rule name = "Disable port 137 - UDP" dir = in action = block protocol = UDP localport = 137
 echo. 
 echo 正在屏蔽138端口 请稍候
 netsh advfirewall firewall delete rule name = "Disable port 138 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 138 - TCP" dir = in action = block protocol = TCP localport = 138
 echo. 
 netsh advfirewall firewall delete rule name = "Disable port 138 - UDP"
 netsh advfirewall firewall add rule name = "Disable port 138 - UDP" dir = in action = block protocol = UDP localport = 138
 echo. 
 echo 正在屏蔽139端口 请稍候
netsh advfirewall firewall delete rule name = "Disable port 139 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 139 - TCP" dir = in action = block protocol = TCP localport = 139
 echo. 
 netsh advfirewall firewall delete rule name = "Disable port 139 - UDP"
 netsh advfirewall firewall add rule name = "Disable port 139 - UDP" dir = in action = block protocol = UDP localport = 139
 echo. 
 echo 正在关闭445端口 请稍候
netsh advfirewall firewall delete rule name = "Disable port 445 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 445 - TCP" dir = in action = block protocol = TCP localport = 445
 echo. 
 netsh advfirewall firewall delete rule name = "Disable port 445 - UDP"
 netsh advfirewall firewall add rule name = "Disable port 445 - UDP" dir = in action = block protocol = UDP localport = 445
 echo.

 echo. 
 echo 正在关闭443端口 请稍候
netsh advfirewall firewall delete rule name = "Disable port 443 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 443 - TCP" dir = in action = block protocol = TCP localport = 443


 echo.
 echo 正在关闭3389端口 请稍候
netsh advfirewall firewall delete rule name = "Disable port 3389 - TCP"
 netsh advfirewall firewall add rule name = "Disable port 3389 - TCP" dir = in action = block protocol = TCP localport = 3389

 echo "危险端口已经用Windows防火墙屏蔽成势

 echo.
 echo ----------------
 echo “正在关闭Workstation(LanmanWorkstation)服务
sc stop LanmanWorkstation
 sc config LanmanWorkstation start= disabled

 echo.
 echo ----------------
 echo “正在关闭Server(LanmanServer)服务
sc stop LanmanServer
 sc config LanmanServer start= disabled

 echo.
 echo ----------------
 echo “正在关闭TCP/IP NetBIOS Helper(lmhosts)共享服务
sc stop lmhosts
 sc config lmhosts start= disabled

 echo.
 echo ----------------
 echo “正在关闭Distributed Transaction Coordinator(MSDTC)共享服务
sc stop MSDTC
 sc config MSDTC start= disabled

 echo.
 echo ----------------
 echo “正在关闭NetBT服务
sc stop NetBT
 sc config NetBT start= disabled

 echo.
 echo ----------------
 echo “正在关闭Distributed TermService 远程桌面服务
sc stop TermService
 sc config TermService start= disabled



 echo.
 echo ----------------
 reg add "hklm\System\CurrentControlSet\Services\NetBT\Parameters" /v "SMBDeviceEnabled" /t reg_dword /d "0" /f
 reg add "hklm\SOFTWARE\Microsoft\Ole" /v "EnableDCOM" /t reg_sz /d "N" /f
 reg add "hklm\SOFTWARE\Microsoft\Rpc" /v "DCOM Protocols" /t reg_multi_sz /d "" /f

 echo.
 echo ----------------
 echo "恭喜您,危险端口已经关闭,请重新启动电脑后用netstat -an查看本地端口"
goto menu

:cmd5

@echo off
net share iPC$ /delete
net share admin$ /delete
net share c$ /delete
net share d$ /delete
net share e$ /delete
net share f$ /delete
net share g$ /delete

echo 关闭完毕
goto menu 

猜你喜欢

转载自blog.csdn.net/weixin_44019506/article/details/104819741