Python Forum

Full Version: Code to change LAN Settings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to change LAN settings within IE and LAN adapter settings as part of my script but cannot get it working.
I have a Batch file that currently does this that is called from my Python program but ideally i want everything done within Python.

The functions i require are:

*LAN Settings - Proxy Enable/Disable
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^ /v ProxyEnable /t REG_DWORD /d 0 /f
*LAN Settings - Add Proxy Address
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d 10.xxx.x.x:80 /f
*LAN Settings - Auto Detect Settings Enable/Disable
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^ /v AutoDetect /t REG_DWORD /d 1 /f
*Set Static IP Address
netsh int ipv4 set address name="Local Area Connection" source=static address=10.xxx.x.x mask=255.255.255.0 gateway=none
*Set IP Auto Obtain
netsh interface ipv4 set address name="Local Area Connection" source=dhcp

netsh interface ipv4 set dnsservers name="Local Area Connection" source=dhcp
I have tried using subprocess() with no joy i suspect it could be an issue with UAC elevation ??? in my batch file i have some code that automatically elevates to "Run As Administrator" but i cannot find an example of similar code for python.