@echo off
setlocal

rem 获取批处理文件所在目录
set "script_dir=%~dp0"

rem 设置AMon.exe和CBet.exe的路径以及对应的自定义快捷键名称
set "amon_exe=%script_dir%AMon.exe"
set "amon_name=代理端"
set "cbet_exe=%script_dir%CBet.exe"
set "cbet_name=会员端"

rem 设置起始位置为脚本所在目录
set "start_in=%script_dir%"

rem 创建 AMon.exe 的快捷键
call :create_shortcut "%amon_exe%" "%amon_name%"
if %errorlevel% neq 0 exit /b %errorlevel%

rem 创建 CBet.exe 的快捷键
call :create_shortcut "%cbet_exe%" "%cbet_name%"
if %errorlevel% neq 0 exit /b %errorlevel%

echo All shortcuts created successfully.
exit /b 0

:create_shortcut
set "exe_path=%~1"
set "shortcut_name=%~2"

rem 创建快捷键
set "desktop_dir=%userprofile%\Desktop"
set "shortcut_file=%desktop_dir%\%shortcut_name%.lnk"

rem 检查桌面是否已存在同名快捷方式
if exist "%shortcut_file%" (
    echo Error: Shortcut '%shortcut_name%' already exists on the desktop.
    exit /b 1
)

rem 创建快捷键并设置起始位置
echo Creating shortcut for %exe_path% as '%shortcut_name%' on the desktop...
powershell -command "$WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%shortcut_file%'); $Shortcut.TargetPath = '%exe_path%'; $Shortcut.WorkingDirectory = '%start_in%'; $Shortcut.Save()"

exit /b 0
