@echo off
:: ===============================================================================
:: AppFileName:	App.bat
:: Date:		2025-04-22 10:27:16
:: Version:		2025-04-22
:: Author:		lsl
:: ===============================================================================
::
rem ====----	EndCmd
if "%~1"=="" (
	set "%~n0EndCmd=k"
) else (
	set "%~n0EndCmd=c"
)

if "%~2"=="" (
	set "App_Folder=%ConfFile%"
) else (
	set "App_Folder=%~2"
)

if "%~3"=="" (
	set "InstallType=all"
) else (
	set "InstallType=%~3"
)

rem ====----	IsAdmin
rem ====	基本系統設定 set 一定要加""避免空白
set "Driver=%~d0"
set "FilePath=%~p0"
set "ConfFile=%~n0"
set "FullPath=%~dp0"
set "FullPathFile=%~f0"
rem ====----	IsAdmin
call :IsAdmin

TITLE %ConfFile%

set App_Folder=%ConfFile%

if /I %InstallType% EQU curl (
	call InstallApp.bat c %App_Folder% curl
)

if /I %InstallType% EQU all (
	call InstallApp.bat c %App_Folder% all
	call InstallApp.bat c %App_Folder% Desktop
)

if /I %InstallType% EQU Desktop (
	call InstallApp.bat k %App_Folder% Desktop
)

if /I %InstallType% EQU Shortcut (
	call InstallApp.bat k %App_Folder% Shortcut
)

goto End

:IsAdmin
	reg.exe query "HKU\S-1-5-19\Environment" >nul
	if not %ERRORLEVEL% EQU 0 (
		echo 必須「以系統管理員身分執行」
		echo You must have administrator rights to continue ...
		pause & exit
	)
	exit /b

:End
	cd /D "%Driver%%FilePath%"

	FOR /f "tokens=1-2 delims==" %%A in ('set %~n0EndCmd') do (
		set EndCmd=%%B
	)
	%ComSpec% /%EndCmd%
