Skip to main content

Command Palette

Search for a command to run...

PowerShell Script: Configure Internet Proxy Settings (Per User)

Published
•4 min read•View as Markdown
T

Software Engineer

đź§ľ Purpose:

This script configures Internet Properties (LAN Settings) on a Windows machine using PowerShell. It ensures proxy settings are applied at the user level, bypassing system-wide Group Policy enforcement that prevents changes from reflecting in the Internet Options UI.


âś… Features:

  • Enables per-user proxy configuration (ProxySettingsPerUser)

  • Disables "Automatically detect settings"

  • Enables "Use a proxy server for your LAN"

  • Sets a custom proxy server address and port

  • Enables "Bypass proxy server for local addresses"

  • Refreshes Internet Settings to apply changes


⚠️ Prerequisites:

  • Must be run as Administrator

  • Intended for Windows systems with access to modify the registry


đź“‚ Registry Paths Used:

ScopePath
System (HKLM)HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
User (HKCU)HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

đź’» Script:

powershellCopyEdit# Allow per-user proxy settings by enabling ProxySettingsPerUser
$machineRegPath = "HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings"
if (-Not (Test-Path $machineRegPath)) {
    New-Item -Path $machineRegPath -Force | Out-Null
}
Set-ItemProperty -Path $machineRegPath -Name ProxySettingsPerUser -Value 1 -Type DWord

# Define user-specific proxy settings
$proxyAddress = "http=your.proxy.url:8080"  # Replace with your actual proxy
$userRegPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

# Apply the proxy settings
Set-ItemProperty -Path $userRegPath -Name AutoDetect -Value 0                     # Disable "Automatically detect settings"
Set-ItemProperty -Path $userRegPath -Name ProxyEnable -Value 1                   # Enable proxy
Set-ItemProperty -Path $userRegPath -Name ProxyServer -Value $proxyAddress       # Set proxy server
Set-ItemProperty -Path $userRegPath -Name ProxyOverride -Value "<local>"         # Bypass for local addresses

# Optionally refresh Internet settings for immediate effect
rundll32.exe inetcpl.cpl,ClearMyTracksByProcess 4351

Write-Host "Proxy settings applied. UI should now reflect the changes."

đź§Ş Post-Execution Verification:

  1. Open regedit and confirm changes under:

    • HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings

    • HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings

  2. Launch Internet Properties → Connections → LAN Settings

    • "Use a proxy server" is checked âś…

    • Proxy server address is set âś…

    • "Bypass proxy for local addresses" is checked âś…

    • "Automatically detect settings" is unchecked âś…


📌 Notes:

  • ProxySettingsPerUser=1 is crucial to allow user-level changes and avoid the "Some settings are managed by your system administrator" warning.

  • Changes apply instantly in most cases; if not, log off/log on or restart browser applications.

Step 1: Enable per-user proxy settings

powershellCopyEdit$machineRegPath = "HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings"
if (-Not (Test-Path $machineRegPath)) {
    New-Item -Path $machineRegPath -Force | Out-Null
}
Set-ItemProperty -Path $machineRegPath -Name ProxySettingsPerUser -Value 1 -Type DWord
  • What’s happening?

    • The first part checks if a specific setting (called ProxySettingsPerUser) exists in a special part of your system’s configuration, called the registry.

    • Why? This setting decides if you can change proxy settings just for your own user (which we want) or if they are locked for everyone on the computer.

    • If it doesn’t exist, the script creates it. Then, it sets the value of ProxySettingsPerUser to 1, which means yes, you are allowed to modify your own settings.


Step 2: Define proxy server settings

powershellCopyEdit$proxyAddress = "http=your.proxy.url:8080"  # Replace with your actual proxy
$userRegPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
  • What’s happening?

    • Here, we’re telling the script the proxy server’s address and port (like http=your.proxy.url:8080).

    • The $userRegPath is the path where your individual (user) settings are stored in the registry. This is where we’ll apply the actual proxy settings.


Step 3: Apply the actual proxy settings

powershellCopyEditSet-ItemProperty -Path $userRegPath -Name AutoDetect -Value 0                     # Disable "Automatically detect settings"
Set-ItemProperty -Path $userRegPath -Name ProxyEnable -Value 1                   # Enable proxy
Set-ItemProperty -Path $userRegPath -Name ProxyServer -Value $proxyAddress       # Set proxy server
Set-ItemProperty -Path $userRegPath -Name ProxyOverride -Value "<local>"         # Bypass for local addresses
  • What’s happening?

    • The Set-ItemProperty command is where we are actually setting or modifying the settings.

    • The settings are for:

      1. AutoDetect: We turn off the "Automatically detect settings" option (by setting it to 0), so Windows won’t try to guess the proxy.

      2. ProxyEnable: We turn on the proxy by setting it to 1.

      3. ProxyServer: We tell the computer the address and port of the proxy server.

      4. ProxyOverride: We tell the computer to bypass the proxy for local addresses (like your local network).


Step 4: Refresh the settings immediately

powershellCopyEditrundll32.exe inetcpl.cpl,ClearMyTracksByProcess 4351
  • What’s happening?

    • This command forces a refresh of Internet Settings, so the changes take effect right away. It’s like telling your computer to clear any old settings and reload the new ones you just applied.

Final Message:

powershellCopyEditWrite-Host "Proxy settings applied. UI should now reflect the changes."
  • What’s happening?

    • The script prints a message to the screen, telling you that the proxy settings have been applied successfully.