Como verificar qual navegador é o principal?

1

Existe alguma maneira de verificar qual navegador é primário em uma máquina específica em um Windows 10? Como posso encontrar essa informação programaticamente? Powershell talvez? Ou Python? Obrigado por qualquer sugestão.

    
por hod 14.11.2017 / 17:24

2 respostas

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

do prompt de comando do Windows deve retornar (valores legíveis, por exemplo, FirefoxURL , ChromeHTML , IE.HTTP ) Progid para a maioria dos protocolos (principalmente ftp , http , https etc.), e. da seguinte forma:

==> 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

…

Atualizado : um script do powershell - mais maneiras de resolver.

'### 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'

Exemplo de saída (parcialmente truncado):

PS D:\PShell> D:\PShell\SU68295.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

Atualização 2 - saída depois de tornar o navegador padrão Firefox :

PS D:\PShell> D:\PShell\SU68295.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
    
por 14.11.2017 / 18:22
0

Existe alguma maneira de verificar qual navegador é primário em uma máquina específica

O navegador principal pode ser diferente dependendo do protocolo ao qual você está se referindo.

Você pode usar ftype em um shell cmd para verificar os diferentes protocolos.

Exemplos:

> 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 ...

Leitura Adicional

por 14.11.2017 / 22:59