mirror of
https://github.com/Andre-Bzk/SunshineDisplaySwitch.git
synced 2026-11-15 09:33:11 +01:00
17 lines
997 B
Batchfile
17 lines
997 B
Batchfile
@echo off
|
|
REM Selbst-Elevation: fordert Admin-Rechte via UAC-Dialog an
|
|
net session >nul 2>&1
|
|
if %errorLevel% neq 0 (
|
|
powershell -Command "Start-Process '%~f0' -Verb RunAs"
|
|
exit /b
|
|
)
|
|
|
|
REM Angemeldeten Benutzer ermitteln (nicht SYSTEM)
|
|
for /f "tokens=*" %%u in ('powershell -NoProfile -Command "(Get-WMIObject Win32_ComputerSystem).Username"') do set CURRENT_USER=%%u
|
|
|
|
powershell.exe -ExecutionPolicy Bypass -NonInteractive -Command "$action = New-ScheduledTaskAction -Execute 'DisplaySwitch.exe' -Argument '/internal'; $principal = New-ScheduledTaskPrincipal -UserId '%CURRENT_USER%' -LogonType Interactive -RunLevel Highest; $settings = New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -ExecutionTimeLimit (New-TimeSpan -Minutes 1); Register-ScheduledTask -TaskName 'MoonlightTeardown' -Action $action -Principal $principal -Settings $settings -Force; Write-Host 'Task MoonlightTeardown erfolgreich registriert.'"
|
|
|
|
echo.
|
|
echo Fertig. Dieses Fenster kann geschlossen werden.
|
|
pause
|