From dbee26db5f71b229d01a56ab9cf0593a2cafdafc Mon Sep 17 00:00:00 2001 From: duffyduck Date: Mon, 22 Dec 2025 18:24:05 +0100 Subject: [PATCH] =?UTF-8?q?vbs.script=20launcher=20f=C3=BCr=20sonderzeiche?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Freigabe-Launcher.vbs | 24 ++++++++++++++++++++++++ Install-FreigabeKontextmenue.ps1 | 9 +++++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Freigabe-Launcher.vbs diff --git a/Freigabe-Launcher.vbs b/Freigabe-Launcher.vbs new file mode 100644 index 0000000..e64b976 --- /dev/null +++ b/Freigabe-Launcher.vbs @@ -0,0 +1,24 @@ +' Launcher fuer Freigabe-Skripte +' Umgeht Probleme mit Sonderzeichen (& etc.) in Pfaden + +Set objArgs = WScript.Arguments +If objArgs.Count < 2 Then + WScript.Quit 1 +End If + +strAction = objArgs(0) +strPath = objArgs(1) + +Set objShell = CreateObject("WScript.Shell") +strScriptDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "") + +If strAction = "add" Then + strScript = strScriptDir & "Freigabe-Hinzufuegen.ps1" +ElseIf strAction = "remove" Then + strScript = strScriptDir & "Freigabe-Entfernen.ps1" +Else + WScript.Quit 1 +End If + +strCommand = "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File """ & strScript & """ -Path """ & strPath & """" +objShell.Run strCommand, 0, False diff --git a/Install-FreigabeKontextmenue.ps1 b/Install-FreigabeKontextmenue.ps1 index a90a500..7b827dc 100644 --- a/Install-FreigabeKontextmenue.ps1 +++ b/Install-FreigabeKontextmenue.ps1 @@ -118,6 +118,7 @@ function Install-ContextMenu { $scriptDir = Get-ScriptDirectory $freigabeScript = Join-Path $scriptDir "Freigabe-Hinzufuegen.ps1" $entfernenScript = Join-Path $scriptDir "Freigabe-Entfernen.ps1" + $launcherScript = Join-Path $scriptDir "Freigabe-Launcher.vbs" if ($ForAllUsers) { if (-not (Test-Administrator)) { @@ -164,9 +165,9 @@ function Install-ContextMenu { } if ($shellType -eq "Directory\Background\shell") { - Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "cmd /c powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$freigabeScript`" -Path `"`"%V`"`"" + Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "wscript.exe `"$launcherScript`" add `"%V`"" } else { - Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "cmd /c powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$freigabeScript`" -Path `"`"%1`"`"" + Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "wscript.exe `"$launcherScript`" add `"%1`"" } if (-not (Test-Path $entfernenKey)) { @@ -181,9 +182,9 @@ function Install-ContextMenu { } if ($shellType -eq "Directory\Background\shell") { - Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "cmd /c powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$entfernenScript`" -Path `"`"%V`"`"" + Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "wscript.exe `"$launcherScript`" remove `"%V`"" } else { - Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "cmd /c powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$entfernenScript`" -Path `"`"%1`"`"" + Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "wscript.exe `"$launcherScript`" remove `"%1`"" } }