PoshCode Archive  Artifact [f21bfaec81]

Artifact f21bfaec81e8d59d10b0451a004ab0437e5285a1a9be216b80d1a11011879e6d:

  • File Set-defaultBrowser.ps1 — part of check-in [e2ef45f7ef] at 2018-06-10 14:03:33 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: 2420)

# 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: 5890
# x-archived: 2017-05-22T18:08:05
# x-published: 2017-06-10T15:42: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
        }
	'Chrome' {
	    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 ff
# Set-defaultBrowser ie