用于检测并修复网络适配器是否需要重置的 Windows 脚本
所有,
是否有任何脚本可以放在调度程序上,仅在网络连接失败时自动重置适配器?
我正在运行 Windows 7
-Jeremy
all,
is there any script that I can put on a scheduler to auto reset adapter only if there is a network connection failure?
I am running Windows 7
-Jeremy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个用于执行此操作的 Powershell 脚本,将 nnnn 替换为您的默认网关 IP 地址,并将连接名称替换为您的连接名称!
将其另存为 filename.ps1(例如),并使用以下命令创建 Windows 计划任务:
Powershell.exe c:\pathtoscript\filename.ps1 -noprofile -Noninteractive
如果您之前没有使用过 powershell,则启动并运行以下命令可确保计划的脚本运行:
Set-ExecutionPolicy RemoteSigned
有关此内容的更多信息:Powershell 执行策略
Here's a Powershell script for doing this, replace n.n.n.n with your Default Gateway IP address and Name of connection with the name of your connection!
Save this as filename.ps1 (for example) and create a Windows scheduled task with the following command:
Powershell.exe c:\pathtoscript\filename.ps1 -noprofile -Noninteractive
If you haven't used powershell before then start it up and run the following command to ensure your scheduled script will run:
Set-ExecutionPolicy RemoteSigned
More on this here: Powershell Execution Policy
我正在尝试检查任何 IP 192.168.1.187,如果失败,它将重置网络适配器“以太网 2”(在我执行 IP 配置时显示)。我认为这实际上与本页顶部问题中描述的用例相同。
我提出以下解决方案,我希望它可以在Win10上运行,尽管我对此不确定。
I am trying to check any IP 192.168.1.187 and if it fails it will reset the network adaptor "Ethernet 2" (which is shown when I perform an IP Config). I consider this to be practically the same use case as described in the question at the top of this page.
I propose the following solution, which I hope works on Win10, though I am not sure about that.