add launcher
This commit is contained in:
35
launcher/setup.bat
Normal file
35
launcher/setup.bat
Normal file
@@ -0,0 +1,35 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set "TASK_NAME=qmt_launcher"
|
||||
set "LAUNCHER_EXE=%~dp0start.exe"
|
||||
if not exist "%LAUNCHER_EXE%" (
|
||||
call "%~dp0build.bat"
|
||||
if errorlevel 1 (
|
||||
echo Failed to prepare start.exe.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||
"$ErrorActionPreference = 'Stop';" ^
|
||||
"$taskName = '%TASK_NAME%';" ^
|
||||
"$launcherDir = (Resolve-Path -LiteralPath '%~dp0').Path;" ^
|
||||
"$workingDir = Split-Path -Parent $launcherDir;" ^
|
||||
"$launcherExe = Join-Path $launcherDir 'start.exe';" ^
|
||||
"$action = New-ScheduledTaskAction -Execute $launcherExe -WorkingDirectory $workingDir;" ^
|
||||
"$trigger = New-ScheduledTaskTrigger -AtLogOn -User ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name);" ^
|
||||
"$principal = New-ScheduledTaskPrincipal -UserId ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name) -LogonType Interactive -RunLevel Highest;" ^
|
||||
"$settings = New-ScheduledTaskSettingsSet -Hidden:$false;" ^
|
||||
"Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null"
|
||||
|
||||
if errorlevel 1 (
|
||||
echo Failed to create task "%TASK_NAME%".
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Task "%TASK_NAME%" created or updated successfully with a visible window.
|
||||
pause
|
||||
exit /b 0
|
||||
Reference in New Issue
Block a user