我有一个用于笔记本电脑的小脚本,我想做得更好.
I have a little script for a laptop and I want to make it better.
我希望该批处理确定以太网连接是否已插入.
I want the batch to determine if the Ethernet connection is plugged or not.
如果插入了以太网,我想使其通过rasdial连接并ping通.如果PC从ping收到响应,则显示连接成功建立".如果ping没有响应,则连接失败".
If Ethernet is plugged, I would like to make it connect via rasdial and to ping. If PC receives response from ping, then to show "Connection established successfully". If no response from ping, then "Connection failed".
如果拔出以太网,则显示无有线连接".
If Ethernet is unplugged, just to show "No wired connection".
这是当前代码:
@echo off rasdial <Dialup_connection_name> <User> <Pass> ping -n 1 -w 3000 www.google >nul if errorlevel 1 ( cls msg * Connection failed exit ) cls msg * Connection established successfully exit推荐答案
netsh interface show interface name="LAN-Verbindung" |find "Verbindungsstatus" |find "Verbunden">nul && echo connected || echo not connected
(这在德语窗口中有效;您必须对其进行本地化)
(this works on a german windows; you have to localize it)
要在批处理文件中看起来更好,可以这样编写:
to look nicer in the batchfile, you can write it like this:
netsh interface show interface name="LAN-Verbindung" ^ |find "Verbindungsstatus" ^ |find "Verbunden">nul ^ && echo connected ^ || echo not connected更多推荐
确定是否已插入/拔出以太网[批处理代码]
发布评论