Proxy settings without login

If we have a machine that needs to use a proxy for all users, we need to setup that proxy first in the settings. For a user to be able to use the proxy settings we defined, we need to first login as the user, launch Internet Explorer interactively in order to configure the changes.

If we have a service account that needs to use it, we can login in the machine manually. However, if we have hundreds of machines this can be unpractical. Luckily there is a workaround that will enable us to use the defined proxy without needing to login manually or open Internet Explorer in all of these machines.

We are describing These ones only need to be performed once:

  1. Login as a user
  2. Open Internet Explorer
  3. Open the Registry Editor
  4. Access HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
  5. Copy the value under the key DefaultConnectionSettings

These steps need to be performed on each machine:

  1. Run the Registry Editor as the service account
  2. Access HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
  3. Copy the saved value to DefaultConnectionSettings of binary type

The second part of the workflow can be automated with Ansible:

- name: Set proxy settings  
  become: yes  
  become_user: "{{ user }}"  
  become_method: runas  
  win_regedit:  
    path: HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections  
    name: DefaultConnectionSettings
    data: "{{ data }}"
    type: binary  
    state: present