@echo off
:: ===============================================================================
:: AppFileName:	7-zip_Shortcut.bat
:: Date:		2025-04-07 05:11:00
:: Version:		2025-04-07
:: Author:		lsl
:: ===============================================================================
::
rem ====----	EndCmd
if "%~1"=="" (
	set "%~n0EndCmd=k"
) else (
	set "%~n0EndCmd=c"
)

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%

if not exist "%ProgramFiles%\7-Zip\7z.exe" (
	call download.cmd App\ini\7-zip.ini all c
) else (
	echo.File exist "%ProgramFiles%\7-Zip\7z.exe"
)

if not exist "%SystemDrive%\Portable\Shortcut\Shortcut.exe" (
	call download.cmd Portable\ini\ShortCut.ini all c
	call download.cmd Portable\ini\Shortcut_cmd.ini all c
	call Portable\Shortcut\MakeShortcut.bat c
) else (
	echo.File exist "%SystemDrive%\PortableApps\Shortcut\Shortcut.exe"
)

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%
