atarjono
Goto Top

Firefox pdf Einstellung verteilen

Hallo zusammen,

mit der *.cfg Datei kann man ja vieles in Firefox ESR einstellen.
Was muss ich tun, damit *.pdf also "applikation/pdf" immer mit dem externen Acrobat Reader (nicht Acrobat in Firefox) geöffnet wird?

Damit in interne FF-Reader deaktiviert wird, habe ich schon geschafft:
lockPref("pdfjs.disabled", true);

Wenn ich aber nur dies habe, dann werden alle *.pdf nur gespeichert, aber nicht geöffnet.

Danke schonmal im vorraus.

Content-Key: 371464

Url: https://administrator.de/contentid/371464

Printed on: April 19, 2024 at 13:04 o'clock

Member: sabines
sabines Apr 18, 2018 at 12:32:04 (UTC)
Goto Top
Member: erikro
erikro Apr 18, 2018 at 15:00:31 (UTC)
Goto Top
Hallo,

ich vermute mal, Du suchst nach einer automatisierbaren Lösung und nicht nach Klickiklicki im Konfigurator. ;)

Wie Dateien behandelt werden, wird in handlers.json festgelegt. Die liegt in

C:\Users\%username%\AppData\Roaming\Mozilla\Firefox\Profiles\bmxkug7c.default

Der entscheidende Eintrag ist:

"application/pdf":{"action":4,"extensions":["pdf"]}  

Ändere 3 auf 4 und es wird das Programm benutzt, dass der Standardreader für PDFs im System ist. Ist Acrobat nicht der Standardreader sieht das so aus

"application/pdf":{"action":2,"extensions":["pdf"],"handlers":[{"name":"AcroRd32.exe","path":"C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroRd32.exe"}]  

hth und liebe Grüße

Erik
Member: atarjono
atarjono Apr 19, 2018 at 11:58:50 (UTC)
Goto Top
@ Sabine:

wie erikro richtig vermutet hat, suche ich nach einer Lösung zum verteilen (ca 700 PC) und nicht wie die MA sich dahin klicken soll..

@ erikro:
ich finde bei mir kein
"handlers.json"
Liegt es evtl., dass wir die ESR Version benutzen?
ff_1
Member: erikro
erikro Apr 19, 2018 at 12:16:35 (UTC)
Goto Top
Seit Version 56 (glaube ich) heißt die Datei so. Bis dahin war das die mimetype.rdf. Aber ich hoffe mal, dass Dein Browser nicht so alt ist. ;)
Member: colinardo
Solution colinardo Apr 19, 2018, updated at Nov 22, 2021 at 17:23:52 (UTC)
Goto Top
Servus,
entweder du wartest bis 8. Mai (Announcing ESR60 with policy engine), denn dann kommt dieser mit einer neuen Policy-Engine, die direktes integrieren via admx ermöglicht, oder du scriptest dir das als Beispiel mit Powershell und deployst das per Anmeldescript z.B. so:
<#
    Deploy Firefox mimetype handler settings (json / rdf)
#>

# Get current Firefox profile folder
$firefoxprofile = "$env:APPDATA\Mozilla\Firefox\$([regex]::match((gc "$env:APPDATA\Mozilla\Firefox\profiles.ini" | out-string),'(?im)(?<=^Default=).*\.default.*').Value.trim())"  
# Path of handlers.json
$handlerjson = "$firefoxprofile\handlers.json"  
# Path of mimeTypes.rdf
$handlerrdf = "$firefoxprofile\mimeTypes.rdf"  

# test if either json or rdf file exists
if (Test-Path $handlerjson){
    write-host "Modifying mimetype settings in 'handlers.json'." -F Green  
    # define mimetype and settings ------------------------------
    $mimetype = 'application/pdf'  
    $settings = [pscustomobject]@{action=4;extensions=@('pdf')}  
    # -----------------------------------------------------------
    # load settings from json
    $json = ConvertFrom-Json (gc $handlerjson)
    # if mime type is defined change settings
    if ($json.mimeTypes.$mimetype -ne $null){
        $json.mimeTypes.$mimetype = $settings
    }else{
        # create mimetype entry with settings
        $json.mimeTypes | Add-Member -MemberType NoteProperty -Name $mimetype -Value $settings -Force
    }
    # write changes back to handlers.json
    $json | ConvertTo-Json -Depth 100 -Compress | sc $handlerjson -Force
}elseif(Test-Path $handlerrdf){
    write-host "Modifying mimetype settings in 'mimeTypes.rdf'." -F Green  
    # load settings from rdf
    $xml = [xml](gc $handlerrdf)
    # define namespace
    $ns = 'http://home.netscape.com/NC-rdf#'  
    # select mimetype node
    $node = $xml.RDF.Description | ?{$_.about -eq 'urn:mimetype:handler:application/pdf'}  
    # set attributes to open pdf with default system pdf handler
    $node.SetAttribute("useSystemDefault",$ns,'true') | out-null  
    $node.SetAttribute("alwaysAsk",$ns,'false') | out-null  
    $node.RemoveAttribute("handleInternal",$ns) | out-null  
    # save settings back nto rdf
    $xml.Save($handlerrdf)
}

back-to-topErgänzung:


Für alle anderen hier noch zwei Funktionen zum einfacheren Konfigurieren der handlers.json mittels CMDLets (Beispiele zur Nutzung der Funktionen findet sich in der Synopsis oberhalb der Funktionen:
<#
.Synopsis
   Add/Set Firefox Browser mimetypes for the current user
.DESCRIPTION
   Add/Set Firefox mimetypes to the current users firefox mimetypes
.EXAMPLE
    Set-FirefoxMimeType -mimetype "application/mms" -extensions 'mms' -handlerpath 'C:\Program Files (x86)\Windows Media Player\wmplayer.exe' -action OpenWithHandler  
   
        set/add mimetype to open with specific application
.EXAMPLE
    Set-FirefoxMimeType -mimetype 'application/pdf' -extensions 'pdf' -action OpenWithFirefox  

        set/add pdf to open with firefox automatically
.EXAMPLE
    Set-FirefoxMimeType -mimetype 'application/pdf' -extensions 'pdf' -action OpenWithHandler -askuser  

        set/add pdf to ask user wich application to use
#>
function Set-FirefoxMimeType {
    param(
        [parameter(mandatory=$true)][string]$mimetype,
        [parameter(mandatory=$true)][string[]]$extensions,
        [parameter(mandatory=$false)][string]$handlerpath,
        [parameter(mandatory=$true)][ValidateSet('SaveAsFile','OpenWithHandler','OpenWithFirefox','OpenWithWindowsDefault')][string]$action,  
        [parameter(mandatory=$false)][switch]$askuser
    )

    # Get current Firefox profile folder
    $firefoxprofile = "$env:APPDATA\Mozilla\Firefox\$([regex]::match((gc "$env:APPDATA\Mozilla\Firefox\profiles.ini" | out-string),'(?im)(?<=^Default=).*\.default.*').Value.trim())"  
    if (!$firefoxprofile){
        Write-Error "Default firefox profile could not be found!" -Category InvalidOperation  
        return
    }
    # Path of handlers.json
    $handlerjson = "$firefoxprofile\handlers.json"  

    # test if json exists
    if (Test-Path $handlerjson){
        write-host "Set mimetype '$mimetype' in 'handlers.json'." -F Green  
        # load settings from json
        $json = ConvertFrom-Json (gc $handlerjson)

        $settings = [ordered]@{
            # wich extensions to handle by entry
            extensions = [array]$extensions
             # what to to 0 = Save file / 2 = open with defined handler / 3 = open with firefox / 4 = open with Windows default application
            action= @{SaveAsFile = 0;OpenWithHandler = 2;OpenWithFirefox = 3; OpenWithWindowsDefault = 4}.$action
            
        }
        # wether to ask user before opening with application or not ($true = yes / $false = no)
        if($askuser.IsPresent){
             $settings.ask = $askuser.IsPresent
             $settings.action = 2
        }

        # only OpenWithHandler needs the following entries
        if($action -eq 'OpenWithHandler'){  
            # add array of handlers
            if ($handlerpath -ne ''){  
                $settings.handlers = @(@{
                    name = [io.path]::GetFileName($handlerpath)
                    path = $handlerpath
                })
            }
        }

        # create settings custom object from hashtable
        $settings = [pscustomobject]$settings

        # if mime type is defined change settings
        if ($json.mimeTypes.$mimetype -ne $null){
            $json.mimeTypes.$mimetype = $settings
        }else{
            # create mimetype entry with settings
            $json.mimeTypes | Add-Member -MemberType NoteProperty -Name $mimetype -Value $settings -Force
        }
        # write changes back to handlers.json
        $json | ConvertTo-Json -Depth 100 -Compress | sc $handlerjson -Force
    }else{
        Write-Warning "File handlers.json not found."  
    }
}

<#
.Synopsis
   Remove Firefox Browser mimetypes for the current user
.DESCRIPTION
   Remove Firefox an existing mimetype from current users firefox mimetypes
.EXAMPLE
   Remove-FirefoxMimeType -mimetype "application/mms"  

   Removings the mimetype 'application/mms' from the current user settings  
#>
function Remove-FirefoxMimeType {
    param(
        # string of the mimetype to remove (ex. "application/pdf")  
        [parameter(mandatory=$true)][ValidateNotNullOrEmpty()][string]$mimetype
    )
        # Get current Firefox profile folder
    $firefoxprofile = "$env:APPDATA\Mozilla\Firefox\$([regex]::match((gc "$env:APPDATA\Mozilla\Firefox\profiles.ini" | out-string),'(?im)(?<=^Default=).*\.default.*').Value.trim())"  
    if (!$firefoxprofile){
        Write-Error "Default firefox profile could not be found!" -Category InvalidOperation  
        return
    }
    # Path of handlers.json
    $handlerjson = "$firefoxprofile\handlers.json"  

    # test if json exists
    if (Test-Path $handlerjson){
        # load settings from json
        $json = ConvertFrom-Json (gc $handlerjson)
        # check if mimetype exists
        if($json.mimeTypes.$mimetype -eq $null){
            Write-Warning "Mimetype '$mimetype' is not present in firefox handlers!"  
            return
        }
        write-host "Removing mimetype '$mimetype' from 'handlers.json'." -F Green  
        # remove mimetype from list
        $json.mimeTypes.psobject.Properties.remove($mimetype)
        # write changes back to handlers.json
        $json | ConvertTo-Json -Depth 100 -Compress | sc $handlerjson -Force
    }
}

Grüße Uwe
Member: atarjono
atarjono Apr 20, 2018 at 06:20:30 (UTC)
Goto Top
@eriko...: jein...
wir haben 52.7.3 ESRM im Einsatz, was aber FF 59.x entpricht...
Trotzdem habe ich "nur" mimetype.rdf.

@solinardo:
Danke für das Script....ich guck mir das mal genauer an.
Wir verteilen FF erst immer nach der Qualify --> 21.08.18.
Member: erikro
erikro Apr 20, 2018 at 06:43:28 (UTC)
Goto Top
Seltsam. ;) Ich dachte, das wäre für alle aktuellen Versionen umgestellt worden.
Member: colinardo
colinardo Apr 20, 2018 updated at 08:06:16 (UTC)
Goto Top
Zur Info: Das Script oben berücksichtigt jetzt nur die handlers.json, bei Bedarf ergänze ich es dir noch für die mimetypes.rdf, das ist ja auch nur ne XML.
Member: colinardo
colinardo Apr 20, 2018 updated at 08:11:58 (UTC)
Goto Top
-edit 10:05- Script wurde angepasst so dass es jetzt beide Einstellungsdateien berücksichtigt (json/rdf). Das sollte für den Übergang zur nativen Policy ausreichen.
Member: atarjono
atarjono Apr 23, 2018 at 13:18:19 (UTC)
Goto Top
@colinadro:
Vielen lieben dank...werde ich mal ausprobieren...