ollise
Goto Top

PDF per CMD öffnen Sonderzeichen

Guten Morgen,
ich möchte per Batch eine PdF mit Edge öffnen.

Problem:
Umlaute und Sonderzeichen. Ich habe schon die Datei auf OEM850 umgestellt.

Ist Zustand batch datei:
start "" msedge "Q:\-1- DSGVO\-1- Datenschutzinformation für Mitarbeiter\Datenschutzinformation für Mitarbeiter.pdf"

bei Egde kommt "an":
file:/Q:/-1-%20DSGVO/-1-file:(Q:/-1-%20Datenschutzinformation%20fnr%20Mitarbeiter/Datenschutzinformation%20fnr%20Mitarbeiter.pdf

Stehe gerade vor der Wand und komme nicht weiter face-wink

Danke

Content-ID: 22660887691

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

Printed on: September 1, 2024 at 08:09 o'clock

BudTerence
BudTerence Aug 08, 2024 at 05:56:27 (UTC)
Goto Top
Moin,

probiere das mal:


@echo off
setlocal

rem Set the PDF file path
set "pdfPath=Q:\-1- DSGVO\-1- Datenschutzinformation für Mitarbeiter\Datenschutzinformation für Mitarbeiter.pdf"

rem Use PowerShell to URL-encode the path and open it with Edge
powershell -command "Start-Process 'msedge' (('file:///%s' -f [System.Web.HttpUtility]::UrlPathEncode('%pdfPath%')).Replace('\','/'))"

endlocal
OlliSe
OlliSe Aug 08, 2024 at 06:02:15 (UTC)
Goto Top
Hey,
der Typ [system.Web.httpUtility] wurde nciht gefunden ...
BudTerence
BudTerence Aug 08, 2024 at 06:09:48 (UTC)
Goto Top
Dann ist dieser in der standard Powershell Umgebung wohl nicht verfügbar.
Dann halt einen eigenen URL-Encoding-Mechanismus in PowerShell implementieren.

Probiere das mal:

@echo off
setlocal

rem Set the PDF file path
set "pdfPath=Q:\-1- DSGVO\-1- Datenschutzinformation für Mitarbeiter\Datenschutzinformation für Mitarbeiter.pdf"

rem Use PowerShell to URL-encode the path and open it with Edge
powershell -command ^
"$path='%pdfPath%';" ^
"$urlEncodedPath=[System.String]::Join('/', $path -split '\\' | ForEach-Object { $_ -replace ' ', '%20' -replace 'ä', '%C3%A4' -replace 'ö', '%C3%B6' -replace 'ü', '%C3%BC' -replace 'ß', '%C3%9F' });" ^
"Start-Process 'msedge' ('file:///' + $urlEncodedPath)"

endlocal
TK1987
TK1987 Aug 08, 2024 updated at 06:11:34 (UTC)
Goto Top
Moin,

Zitat von @OlliSe:
Ist Zustand batch datei:
start "" msedge "Q:\-1- DSGVO\-1- Datenschutzinformation für Mitarbeiter\Datenschutzinformation für Mitarbeiter.pdf"

bei Egde kommt "an":
file:/Q:/-1-%20DSGVO/-1-file:(Q:/-1-%20Datenschutzinformation%20fnr%20Mitarbeiter/Datenschutzinformation%20fnr%20Mitarbeiter.pdf
Leerzeichen gibt es in URL-Pfaden nicht, dass diese durch "%20" ersetzt werden, ist ganz normal und funktioniert auch problemlos.

Dein eigentliches Problem ist hier das "ü". Speichere dein Skript in UTF8-Kodierung (ohne BOM) und ergänze folgende Zeile am Anfang deines Skripts:
>nul chcp 65001

Gruß Thomas
Xaero1982
Xaero1982 Aug 08, 2024 at 06:11:55 (UTC)
Goto Top
Moin,

1. Kurznamen verwenden
dir /x "Q:\-1- DSGVO"  
Damit kannst du ihn auslesen. Sollte so aussehen:

start "" msedge "Q:\-1-DSGVO\-1-~1\Datens~1.pdf"  

Oder
2. Mal mit UNC Pfad versuchen

Grüße
OlliSe
OlliSe Aug 08, 2024 updated at 06:54:13 (UTC)
Goto Top
Hi,
hiermit öffnet er zumindest das Verzeichnis wo ich hin will:

start "" msedge "\\file1\PF-File\IT+Rest\-11- QM\-1- DSGVO\-1-~1\"

Aber sobald ich:
Datens~1.pdf da hinter schrieb, sagt er file not found ...
TK1987
Solution TK1987 Aug 08, 2024 updated at 06:59:48 (UTC)
Goto Top
@echo off
>nul chcp 65001

start "" msedge "Q:\-1- DSGVO\-1- Datenschutzinformation für Mitarbeiter\Datenschutzinformation für Mitarbeiter.pdf"  
funktioniert vollkommen problemlos...
b5f9c9d75c2e8221cfce07d53650471e
OlliSe
OlliSe Aug 08, 2024 at 07:05:52 (UTC)
Goto Top
Zitat von @TK1987:

@echo off
>nul chcp 65001

start "" msedge "Q:\-1- DSGVO\-1- Datenschutzinformation für Mitarbeiter\Datenschutzinformation für Mitarbeiter.pdf"  
funktioniert vollkommen problemlos...
b5f9c9d75c2e8221cfce07d53650471e

Warum ich da so vor der Wand stand ...

Danke !!
Pjordorf
Pjordorf Aug 08, 2024 at 13:26:10 (UTC)
Goto Top
Hallo,

Zitat von @OlliSe:
Warum ich da so vor der Wand stand ...
Weil dir ein bund Petersilie dein Blick versperrte.

Gruss,
Peter