用于更改 LAN 配置的批处理文件已停止工作

用于更改 LAN 配置的批处理文件已停止工作

我有一个批处理脚本,用于将流量引导至代理服务器和从代理服务器引导流量。直到最近,它都运行正常。除去那些多余的东西,这个脚本基本上是这样的:

rem First switch to .201 default gateway
netsh interface ipv4 set address name="Local Area Connection" static 10.0.100.100 255.255.252.0 10.0.100.201
ping -n 5 127.0.0.1 >nul

rem Next, turn the LAN automatic configuration script off
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "" /f
ping -n 5 127.0.0.1 >nul

以下是切换回来的反向操作 -

rem Now switch back to .200 default gateway
netsh interface ipv4 set address name="Local Area Connection" static 10.0.100.100 255.255.252.0 10.0.100.200
ping -n 5 127.0.0.1 >nul

rem Finally, turn the LAN automatic configuration script back on
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "http://10.0.100.236/proxy.pac" /f
ping -n 5 127.0.0.1 >nul

我把 ping 留在那里,以防它们会引起一些软件问题。

我遇到的问题是注册表编辑似乎不再能够更改自动配置脚本。

正如我所说,直到最近它都运行良好。有人能指出可能是什么问题吗?

编辑:我唯一的想法是 Windows 更新可能改变了代码与注册表交互的方式。继续进一步研究,因为这个问题仍然没有答案。

经过进一步检查,当我在命令窗口中运行代码将 AutoConfigURL 更改为“”时,它会按预期工作并适当更改值。那么,为什么如果通过批处理脚本运行它却不起作用呢?

相关内容