PoshCode Archive  Artifact Content

Artifact 2da2f969bb840d23e18948bb4631daf8f5ad1d0cdc676b11068712c924b115e3:

  • File Set-defaultBrowser.ps1 — part of check-in [30a2debc89] at 2018-06-10 13:59:05 on branch trunk — With this function I can switch between Chrome, IE and Firefox as default browser. It is just a start. There might be some more registry keys to be changed (user: Andy Myatt size: 2487)

# encoding: ascii
# api: powershell
# title: Set-defaultBrowser
# description: With this function I can switch between Chrome, IE and Firefox as default browser. It is just a start. There might be some more registry keys to be changed
# version: 0.1
# type: function
# author: Andy Myatt
# license: CC0
# function: Set-defaultBrowser
# x-poshcode-id: 5677
# x-derived-from-id: 5678
# x-archived: 2017-05-13T16:56:12
# x-published: 2017-01-09T09:55:00
#
#
function Set-defaultBrowser
{
    param($defaultBrowser)

    switch ($defaultBrowser)
    {
        'IE' {
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice' -name ProgId IE.FTP
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice' -name ProgId IE.HTTP
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice' -name ProgId IE.HTTPS
            
        }
        'FF' {
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice' -name ProgId FirefoxURL
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice' -name ProgId FirefoxURL
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice' -name ProgId FirefoxURL
        }
        'CR' {
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice' -name ProgId ChromeHTML
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice' -name ProgId ChromeHTML
            Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice' -name ProgId ChromeHTML
        }
    } 
    
# thanks to http://newoldthing.wordpress.com/2007/03/23/how-does-your-browsers-know-that-its-not-the-default-browser/
        
<#
(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice').ProgId
(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice').ProgId
(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice').ProgId
#>

}

# Set-defaultBrowser cr
# Set-defaultBrowser ff
# Set-defaultBrowser ie