使用 Windows 任务计划程序进行自动网络防火墙身份验证

发布于 2025-01-11 13:28:17 字数 498 浏览 5 评论 0原文

我的大学要求学生定期进行身份验证才能使用 WiFi 和 LAN。我正在编写一个 Python 脚本,它会自动执行此操作,这样我就不必手动输入我的凭据。 WiFi 和 LAN 的身份验证也是分开的,这使得我在它们之间切换时需要输入我的凭据。因此,对于 python 脚本,我想检测我的身份验证何时过期以及我的连接何时断开。

我也不希望 python 脚本在后台不断运行并对网站执行 ping 操作,因为这确实不是最佳选择,而且每次电脑重新启动时我都必须运行该脚本。我正在考虑使用 Windows 任务计划程序在检测到我的连接丢失时触发该脚本。触发事件不能是固定间隔,因为在间隔之间以及在 LAN 和 WiFi 之间切换时,连接可能会丢失。

那么,是否有任何网络事件可以捕获我想要的功能?当 Windows 发出“打开浏览器进行连接”的通知时,我觉得必须有一个后台事件正在运行。

我尝试了任务计划程序中的网络配置文件/操作事件,事件 ID 为 10001 和 8003。但是当我关闭 PC 的 WiFi 时,该事件就会触发。

谢谢

My college requires students to periodically authenticate for using WiFi and LAN. I am writing a Python script that will automatically do that so that I don't have to manually enter my credentials. The authentication is also separate for WiFi and LAN, and that makes me enter my credentials when I switch between them. So, for the python script, I want to detect when my authentication has expired and my connection is disconnected.

I also don't want the python script to be running constantly in the background and pinging a website as that really isn't optimal and I'll have to run the script every time my PC restarts. I was thinking of using the Windows Task Scheduler to fire the script when it detects that my connection is lost. The trigger event cannot be fixed intervals as the connection can be lost in between the intervals and also when switching between LAN and WiFi.

So, is there any network event that will capture the functionality I want? As Windows gives a notification of "opening the browser to connect" I feel there has to be a background event running.

I tried the NetworkProfile/Operational Event in the Task Scheduler with event id 10001 and 8003. But that just fires when I switch off the WiFi of my PC.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执着的年纪 2025-01-18 13:28:18

知道了!

ID 为 4002 的网络配置文件/操作事件等待网络身份验证。

Got it!

NetworkProfile/Operational Event with ID 4002 waits for network authentication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文