taskkill /f /im Battle.net.exe /t

rmdir "%~dp0ICafeCloud\LocalAppData\Account" /S /Q

rmdir "%LocalAppData%\Battle.net" /S /Q
rmdir "%ProgramData%\Battle.net" /S /Q
rmdir "%ProgramData%\Battle.net_components" /S /Q
mklink /J  "%LocalAppData%\Battle.net" "%~dp0ICafeCloud\LocalAppData"
mklink /J  "%ProgramData%\Battle.net" "%~dp0ICafeCloud\ProgramData\Battle.net"
mklink /J  "%ProgramData%\Battle.net_components" "%~dp0ICafeCloud\ProgramData\Battle.net_components"

Reg.exe add "HKCR\battlenet" /f /ve /t REG_SZ /d "URL:Blizzard Battle.net Protocol"
Reg.exe add "HKCR\battlenet" /f /v "URL Protocol" /t REG_SZ /d ""
Reg.exe add "HKCR\battlenet\DefaultIcon" /f /ve /t REG_SZ /d "\"%~dp0\Battle.net.exe\",0"
Reg.exe add "HKCR\battlenet\shell\open\command" /f /ve /t REG_SZ /d "\"%~dp0\Battle.net.exe\" --uri=\"%%1\""

set "script_dir=%~dp0"
set "shortcut_exe_path=%~dp0Battle.net Launcher.exe"
set "shortcut_work_dir=%script_dir:~0,-1%"
set "shortcut_name=Battle.net"
set "desktop_folder=%USERPROFILE%\Desktop"

powershell -Command "$s=(New-Object -ComObject WScript.Shell).CreateShortcut('%desktop_folder%\%shortcut_name%.lnk'); $s.TargetPath='%shortcut_exe_path%'; $s.WorkingDirectory='%shortcut_work_dir%'; $s.Save()"