如何检查哪个浏览器是主要浏览器?

如何检查哪个浏览器是主要浏览器?

有没有办法检查 Windows 10 上特定机器上的主浏览器是什么?我如何以编程方式找到该信息?也许可以使用 Powershell?或者 Python?感谢您的任何建议。

答案1

reg query "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations" -v Progid -s

从 Windows 命令提示符应该返回大多数协议(主要是、等)的值(人类可读的,例如FirefoxURL、、)例如如下所示:ChromeHTMLIE.HTTPProgidftphttphttps

==> reg query "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations" -v Progid -s

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice
    ProgId    REG_SZ    ChromeHTML

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice
    ProgId    REG_SZ    ChromeHTML

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice
    ProgId    REG_SZ    ChromeHTML

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\irc\UserChoice
    ProgId    REG_SZ    ChromeHTML

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\mailto\UserChoice
    ProgId    REG_SZ    ChromeHTML

更新:powershell 脚本-更多解决方法。

'### by …\Shell\Associations\UrlAssociations'
$ProgidHash = @{}
$RegPath = "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations"
Get-ChildItem "$RegPath\*\UserChoice\" -ErrorAction SilentlyContinue | 
    ForEach-Object { 
        $ProgidHash.Add( (get-item $_.PSParentPath).PSChildName, 
                         $_.GetValue('progId')) }
if ( $ProgidHash.Count -gt 0 ) {Write-Output $ProgidHash}

'### by URL protocol (incomplete list)'
$ProtoHash = @{}
$RegPathCU = 'HKCU:\Software\Classes'
$regPathLM = 'HKLM:\SOFTWARE\Classes'
'ftp', 'http', 'https', 'mailto', 'ms-mail', 'news' | 
    ForEach-Object {
        if       ( Test-Path "$RegPathCU\$_\shell\open\command" ) {
            $ProtoHash.Add( "$_", 
            ('HKCU', ('"' + $((Get-Item "$RegPathCU\$_\shell\open\command").GetValue('') | 
                Split-Path -Leaf))))
        } elseif ( Test-Path "$RegPathLM\$_\shell\open\command" ) {
            $ProtoHash.Add( "$_", 
            ('HKLM', ('"' + $((Get-Item "$RegPathLM\$_\shell\open\command").GetValue('') | 
                Split-Path -Leaf))))
        } else {
            $ProtoHash.Add( "$_", ('none', [string]::Empty))
        }
    }
if ( $ProtoHash.Count -gt 0) { Write-Output $ProtoHash }

'### by file extension (incomplete list)'
$ExtenHash = @{}
$RegPathCU = 'HKCU:\Software\Classes'
$regPathLM = 'HKLM:\SOFTWARE\Classes'
'.htm', '.html', '.shtml', '.xhtml', '.xml' | 
    ForEach-Object {
        if       ( Test-Path -LiteralPath "$RegPathCU\$_" ) {
            $aux = (Get-Item "$RegPathCU\$_").GetValue('')
            $ExtenHash.Add( "$_", 
            ('HKCU', $aux, ('"' +  $((Get-Item "$RegPathLM\$aux\shell\open\command").GetValue('') | 
                Split-Path -Leaf))))

        } elseif ( Test-Path -LiteralPath "$RegPathLM\$_" ) {
            $aux = (Get-Item "$RegPathLM\$_").GetValue('')
            $ExtenHash.Add( "$_", 
            ('HKLM', $aux, ('"' + $((Get-Item "$RegPathLM\$aux\shell\open\command").GetValue('') | 
                Split-Path -Leaf))))
        } else {
            $ExtenHash.Add( "$_", ('none', 'none', [string]::Empty))
        }
    }
if ( $ExtenHash.Count -gt 0) { $ExtenHash }

'### TODO: by mime type'

示例输出(部分截断):

PS D:\PShell> D:\PShell\SU\1268295.ps1
### by …\Shell\Associations\UrlAssociations

Name                           Value                                               
----                           -----                                               
urn                            ChromeHTML                                          
news                           ChromeHTML                                          
http                           ChromeHTML                                          
mms                            ChromeHTML                                          
nntp                           ChromeHTML                                          
ftp                            ChromeHTML                                          
mailto                         ChromeHTML                                          
https                          ChromeHTML                                          
smsto                          ChromeHTML                                          
sms                            ChromeHTML                                          
### by URL protocol (incomplete list)
http                           {HKCU, "chrome.exe" -- "%1"}                        
ftp                            {HKCU, "chrome.exe" -- "%1"}                        
news                           {none, }                                            
mailto                         {HKCU, "chrome.exe" -- "%1"}                        
https                          {HKCU, "chrome.exe" -- "%1"}                        
ms-mail                        {none, }                                            
### by file extension (incomplete list)
.xhtml                         {HKCU, ChromeHTML, "chrome.exe" -- "%1"}            
.html                          {HKCU, ChromeHTML, "chrome.exe" -- "%1"}            
.htm                           {HKCU, ChromeHTML, "chrome.exe" -- "%1"}            
.shtml                         {HKCU, ChromeHTML, "chrome.exe" -- "%1"}            
.xml                           {HKLM, xmlfile, "iexplore.exe" %1}                  
### TODO: by mime type

更新 2- 设置默认浏览器后的输出Firefox

PS D:\PShell> D:\PShell\SU\1268295.ps1
### by …\Shell\Associations\UrlAssociations

Name                           Value                                               
----                           -----                                               
urn                            ChromeHTML                                          
news                           ChromeHTML                                          
http                           FirefoxURL-308046B0AF4A39CB                         
mms                            ChromeHTML                                          
nntp                           ChromeHTML                                          
ftp                            FirefoxURL-308046B0AF4A39CB                         
mailto                         ChromeHTML                                          
https                          FirefoxURL-308046B0AF4A39CB                         
smsto                          ChromeHTML                                          
sms                            ChromeHTML                                          
### by URL protocol (incomplete list)
http                           {HKCU, "firefox.exe" -osint -url "%1"}              
ftp                            {HKCU, "firefox.exe" -osint -url "%1"}              
news                           {none, }                                            
mailto                         {HKCU, "chrome.exe" -- "%1"}                        
https                          {HKCU, "firefox.exe" -osint -url "%1"}              
ms-mail                        {none, }                                            
### by file extension (incomplete list)
.xhtml                         {HKCU, FirefoxHTML-308046B0AF4A39CB, "firefox.exe...
.html                          {HKCU, FirefoxHTML-308046B0AF4A39CB, "firefox.exe...
.htm                           {HKCU, FirefoxHTML-308046B0AF4A39CB, "firefox.exe...
.shtml                         {HKCU, FirefoxHTML-308046B0AF4A39CB, "firefox.exe...
.xml                           {HKLM, xmlfile, "iexplore.exe" %1}                  
### TODO: by mime type

答案2

有没有办法检查特定机器上的主要浏览器是哪个

根据您所指的协议,主浏览器可能会有所不同。

您可以在 shellftype中使用cmd它来检查不同的协议。

例子:

> ftype | findstr http
http="C:\apps\Firefox\firefox.exe" -osint -url "%1"
https="C:\apps\Firefox\firefox.exe" -osint -url "%1"

> ftype | findstr ftp
ftp="C:\apps\Firefox\firefox.exe" -osint -url "%1"

ETC ...


进一步阅读

相关内容