From c32157bfda1ae4791d7598514bb2331f960eefaa Mon Sep 17 00:00:00 2001 From: duffyduck Date: Mon, 22 Dec 2025 18:53:44 +0100 Subject: [PATCH] launcher cmd added --- Freigabe-Launcher.cmd | 15 +++++++++++++++ Freigabe-Launcher.vbs | 24 ------------------------ Install-FreigabeKontextmenue.ps1 | 10 +++++----- 3 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 Freigabe-Launcher.cmd delete mode 100644 Freigabe-Launcher.vbs diff --git a/Freigabe-Launcher.cmd b/Freigabe-Launcher.cmd new file mode 100644 index 0000000..210acdc --- /dev/null +++ b/Freigabe-Launcher.cmd @@ -0,0 +1,15 @@ +@echo off +setlocal EnableDelayedExpansion +set "action=%~1" +set "filepath=%~2" +set "scriptdir=%~dp0" + +if "%action%"=="add" ( + set "script=%scriptdir%Freigabe-Hinzufuegen.ps1" +) else if "%action%"=="remove" ( + set "script=%scriptdir%Freigabe-Entfernen.ps1" +) else ( + exit /b 1 +) + +powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "%script%" -Path "%filepath%" diff --git a/Freigabe-Launcher.vbs b/Freigabe-Launcher.vbs deleted file mode 100644 index e64b976..0000000 --- a/Freigabe-Launcher.vbs +++ /dev/null @@ -1,24 +0,0 @@ -' 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 04498dc..0ebaf36 100644 --- a/Install-FreigabeKontextmenue.ps1 +++ b/Install-FreigabeKontextmenue.ps1 @@ -118,7 +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" + $launcherCmd = Join-Path $scriptDir "Freigabe-Launcher.cmd" if ($ForAllUsers) { if (-not (Test-Administrator)) { @@ -165,9 +165,9 @@ function Install-ContextMenu { } if ($shellType -eq "Directory\Background\shell") { - Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "cmd /s /c `"wscript.exe `"$launcherScript`" add `"`"%V`"`"`"" + Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "cmd.exe /c `"`"$launcherCmd`" add `"%V`"`"" } else { - Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "cmd /s /c `"wscript.exe `"$launcherScript`" add `"`"%1`"`"`"" + Set-ItemProperty -Path $freigabeCmd -Name "(Default)" -Value "cmd.exe /c `"`"$launcherCmd`" add `"%1`"`"" } if (-not (Test-Path $entfernenKey)) { @@ -182,9 +182,9 @@ function Install-ContextMenu { } if ($shellType -eq "Directory\Background\shell") { - Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "cmd /s /c `"wscript.exe `"$launcherScript`" remove `"`"%V`"`"`"" + Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "cmd.exe /c `"`"$launcherCmd`" remove `"%V`"`"" } else { - Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "cmd /s /c `"wscript.exe `"$launcherScript`" remove `"`"%1`"`"`"" + Set-ItemProperty -Path $entfernenCmd -Name "(Default)" -Value "cmd.exe /c `"`"$launcherCmd`" remove `"%1`"`"" } }