launcher cmd added

This commit is contained in:
duffyduck 2025-12-22 18:53:44 +01:00
parent 3739c3eec1
commit c32157bfda
3 changed files with 20 additions and 29 deletions

15
Freigabe-Launcher.cmd Normal file
View File

@ -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%"

View File

@ -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

View File

@ -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`"`""
}
}