PoshCode Archive  Artifact [1633d15ccd]

Artifact 1633d15ccda26ea84f03411a46c93d6148b285a92ef754973b3efc3812c3fce7:

  • File Set-defaultBrowser.ps1 — part of check-in [1761a6a5a5] at 2018-06-10 13:59:04 on branch trunk — With this function I can switch between IE and Firefox as default browser. It is just a start. There might be some more registry keys to be changed (user: Bernd Kriszio size: 2482)

# encoding: ascii
# api: powershell
# title: Set-defaultBrowser
# description: With this function I can switch between 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: Bernd Kriszio
# license: CC0
# function: Set-defaultBrowser
# x-poshcode-id: 5676
# x-derived-from-id: 5677
# x-archived: 2017-05-17T23:56:57
# x-published: 2017-01-09T09:45: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