bat代码需要用到nircmd工具，并且加入环境变量if "%1"=="hide" goto CmdBegin start mshta vbscript:createobject("wscript.shell").run("""%~0"" hide",0)(window.close)&&exit :CmdBegin :main wmic path Win32_VideoController get VideoModeDescription | find "1920 x 1080" || nircmd.exe setdisplay 1920 1080 32 timeout /t 3 goto main
新版icmp监控@echo off set ip=192.168.6.156 set waits=1 set log=log_icmPing.txt :main echo %date% %time% >> %log% ping -n 1 %ip% | findstr /i "来自 一般 超时 失败">>%log% timeout /t %waits% goto main主机tcp端口监控@echo off set ip=192.168.6.156 set port=3389 set waits=1 set log=log_portPing.txt :main echo %date% %time% >> %log% tcping -n 1 %ip% %port% | find "Probing" >> %log% timeout /t %waits% goto main旧版本icmp监控@echo off @title 主机监控 :: by: www.runyf.cn :: 等待用户输入需要监控IP set /p ip=请输入IP地址: :: 请求等待秒数 set waits=1 :: 删除缓存 del *.iptmp :: 设置回显时间格式 set file=%ip%-%date:~0,4%%date:~5,2%%date:~8,2%.txt set echotime=%date:~0,4%%date:~5,2%%date:~8,2% %time% echo %echotime% 目标地址：%ip% 脚本开始执行... echo %echotime% 目标地址：%ip% 脚本开始执行... >> %file% :start @title 主机监控 %ip% :: 设置文件名 set file=%ip%-%date:~0,4%%date:~5,2%%date:~8,2%.txt set tmpfile=%file%.iptmp :: 更新时间 set echotime=%date:~0,4%%date:~5,2%%date:~8,2% %time% :: 进行ping测试 echo|set /p =%echotime% >%tmpfile% ping -n 1 %ip% | findstr /i "来自 一般 超时">>%tmpfile% :: 回显 findstr 2 %tmpfile%>>%file% findstr 2 %tmpfile% :: 等待 timeout /t %waits% > nul goto start
使用bat批处理快速切换网卡配置脚本
运行展示脚本源代码展示:: www.runyf.cn @title 网卡配置修改 by 远方 @echo off :: 可将配置修改成你的网卡名，也可以将网卡名改成eth0 set nic="WLAN" set ping=runyf.cn set count=20 echo 一键修改网卡配置脚本 当前网卡 %nic% echo. echo 1:自动获取 DHCP 2:手动配置 Manual echo 3:配置解析 DNS 4:配置面板 网络连接 echo 5:192.168.0.1/24 6:192.168.1.1/24 echo. set /p choice=请选择设置类型: echo. if "%choice%"=="1" goto ip1 if "%choice%"=="2" goto ip2 if "%choice%"=="3" goto ip3 if "%choice%"=="4" goto ip4 if "%choice%"=="5" goto ip5 if "%choice%"=="6" goto ip6 :ip1 echo 自动获取IP地址.... netsh interface ip set address name = %nic% source = dhcp echo 自动获取DNS服务器.... netsh interface ip set dns name = %nic% source = dhcp echo 设置完成 echo 进行连通性测试 ping -n %count% %ping% exit :ip2 :: 配置信息 set /p addr=请输入IP地址: set /p automask=请输入网络标识位: set /p gateway=请输入网关（回车不设置）: if %automask% == 8 ( set mask=255.0.0.0 ) else if %automask% == 9 ( set mask=255.128.0.0 ) else if %automask% == 10 ( set mask=255.192.0.0 ) else if %automask% == 11 ( set mask=255.224.0.0 ) else if %automask% == 12 ( set mask=255.240.0.0 ) else if %automask% == 13 ( set mask=255.248.0.0 ) else if %automask% == 14 ( set mask=255.252.0.0 ) else if %automask% == 15 ( set mask=255.254.0.0 ) else if %automask% == 16 ( set mask=255.255.0.0 ) else if %automask% == 17 ( set mask=255.255.128.0 ) else if %automask% == 18 ( set mask=255.255.192.0 ) else if %automask% == 19 ( set mask=255.255.224.0 ) else if %automask% == 20 ( set mask=255.255.240.0 ) else if %automask% == 21 ( set mask=255.255.248.0 ) else if %automask% == 22 ( set mask=255.255.252.0 ) else if %automask% == 23 ( set mask=255.255.254.0 ) else if %automask% == 24 ( set mask=255.255.255.0 ) else if %automask% == 25 ( set mask=255.255.255.128 ) else if %automask% == 26 ( set mask=255.255.255.192 ) else if %automask% == 27 ( set mask=255.255.255.224 ) else if %automask% == 28 ( set mask=255.255.255.240 ) else if %automask% == 29 ( set mask=255.255.255.248 ) else if %automask% == 30 ( set mask=255.255.255.252 ) else if %automask% == 31 ( set mask=255.255.255.254 ) else if %automask% == 32 ( set mask=255.255.255.255 ) else ( set mask=255.255.255.0 ) echo 正在设置IP及子网掩码 netsh interface ipv4 set address %nic% static %addr% %mask% %gateway% echo 设置完成 echo 进行连通性测试 ping -n %count% %ping% exit :ip3 :: 配置信息 set /p dns=请输入DNS地址: echo 正在设置DNS服务器 netsh interface ip add dnsservers name=%nic% address=%dns% index=1 validate=no echo 设置完成 echo 进行连通性测试 ping -n %count% %ping% exit :ip4 :: 配置信息 ncpa.cpl exit :ip5 :: 配置信息 set addr=192.168.0.2 set mask=255.255.255.0 set gateway=192.168.0.1 set ping=192.168.0.1 echo 正在设置IP及子网掩码 netsh interface ipv4 set address %nic% static %addr% %mask% %gateway% echo 设置完成 echo 进行连通性测试 ping -n %count% %ping% exit :ip6 :: 配置信息 set addr=192.168.1.2 set mask=255.255.255.0 set gateway=192.168.0.1 set ping=192.168.1.1 echo 正在设置IP及子网掩码 netsh interface ipv4 set address %nic% static %addr% %mask% %gateway% echo 设置完成 echo 进行连通性测试 ping -n %count% %ping% exit
注意编码@echo off setlocal enabledelayedexpansion ::打开系统延时 set /a b=0 dir /b/od ::按时间顺序显示当前文件夹下的所有文件名 pause ::给你反悔时间 for /f "delims=" %%f in ('dir /b/od *.*') do ( if not "%%f"=="%~nx0" ( set /a b+=1 ren "%%f" "!b!%%~xf" echo. !b!%%~xf ) ) pause