From e52aab604cad14cbc1510ee328b2bcb8df516f42 Mon Sep 17 00:00:00 2001 From: duffyduck Date: Mon, 22 Dec 2025 15:52:07 +0100 Subject: [PATCH] Create shortcut in Anf+hrungszeichen egesetzt damit sonderzeichnen erlaubt sind --- Freigabe-Hinzufuegen.ps1 | 4 ++++ Install-FreigabeKontextmenue.ps1 | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Freigabe-Hinzufuegen.ps1 b/Freigabe-Hinzufuegen.ps1 index 1717909..16782c2 100644 --- a/Freigabe-Hinzufuegen.ps1 +++ b/Freigabe-Hinzufuegen.ps1 @@ -341,6 +341,10 @@ try { $itemName = Split-Path -Path $Path -Leaf } + # Ungueltige Zeichen fuer Dateinamen entfernen/ersetzen + # Verboten in Windows-Dateinamen: \ / : * ? " < > | + $itemName = $itemName -replace '[\\/:*?"<>|]', '_' + $shortcutPath = Join-Path $userFolder "$itemName.lnk" $counter = 1 diff --git a/Install-FreigabeKontextmenue.ps1 b/Install-FreigabeKontextmenue.ps1 index 7438545..5605e04 100644 --- a/Install-FreigabeKontextmenue.ps1 +++ b/Install-FreigabeKontextmenue.ps1 @@ -164,9 +164,9 @@ function Install-ContextMenu { } if ($shellType -eq "Directory\Background\shell") { - Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$freigabeScript`" -Path `"%V`"" + Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$freigabeScript`" -Path `"`"%V`"`"" } else { - Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$freigabeScript`" -Path `"%1`"" + Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$freigabeScript`" -Path `"`"%1`"`"" } if (-not (Test-Path $entfernenKey)) { @@ -181,9 +181,9 @@ function Install-ContextMenu { } if ($shellType -eq "Directory\Background\shell") { - Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$entfernenScript`" -Path `"%V`"" + Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$entfernenScript`" -Path `"`"%V`"`"" } else { - Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$entfernenScript`" -Path `"%1`"" + Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$entfernenScript`" -Path `"`"%1`"`"" } }