0

I have a batch script I use to direct my traffic to and from a proxy server. Up until recently it worked flawlessly. Without the fluff - the script is essentially this -

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

Here's the reverse to switch back -

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

I left the pings in there just in case they could be causing some soft of problem.

The issue I'm having is the registry edit no longer seems to be working to change the automatic configuration script.

As I said, it was working perfectly fine until recently. Can anyone point out what may be the issue?

Edit: My only thought is that a windows update could have changed the way the code interacts with the registry. Continuing to look further as this question still goes unanswered.

Upon further review - when I run the code to change the AutoConfigURL to "" in a command window, it works as expected and changes the value appropriately. Why then, if it is run through a batch script does it not work?

5
  • Have you checked the permissions on that registry key? Apr 22, 2019 at 13:18
  • @MisterSmith Where can I find the permissions for a specific key? I am not sure. I'm updating my post with something else I've found. Apr 22, 2019 at 14:39
  • In regedit, right click -> permissions on the "folders" on the left. Also do you have antivirus/antimalware software that's interfering? Apr 22, 2019 at 15:22
  • @MisterSmith Yes, I have full control and read permissions according to that menu. I don't believe I have any interference from software - I haven't seen any messages regarding that. As I updated in my post, in the last few months the code still works in the command line but not when it is in a batch file. Apr 22, 2019 at 20:34
  • Try """" instead of "" for the empty string. (I think a double doublequote inside a batchfile is converted to a single doublequote - which would break the command). If this is the case not sure how the script used to function though. Apr 22, 2019 at 22:28

0

You must log in to answer this question.

Browse other questions tagged .