taskkill /f /im upc.exe /t

mkdir "%~dp0ICafeCloud\LocalAppData" 2>nul
mkdir "%~dp0ICafeCloud\ProgramData\Ubisoft Game Launcher" 2>nul

rmdir "%LocalAppData%\Ubisoft Game Launcher" /S /Q
rmdir "%ProgramData%\Ubisoft\Ubisoft Game Launcher" /S /Q
mklink /J "%LocalAppData%\Ubisoft Game Launcher" "%~dp0ICafeCloud\LocalAppData"
mklink /J "%ProgramData%\Ubisoft\Ubisoft Game Launcher" "%~dp0ICafeCloud\ProgramData\Ubisoft Game Launcher"

Reg.exe add "HKLM\SOFTWARE\Wow6432Node\Ubisoft\Launcher" /f /ve /t REG_SZ /d ""
Reg.exe add "HKLM\SOFTWARE\Wow6432Node\Ubisoft\Launcher" /f /v "InstallDir" /t REG_SZ /d "%~dp0"
Reg.exe add "HKLM\SOFTWARE\Wow6432Node\Ubisoft\Launcher\Installs" /f /ve /t REG_SZ /d ""

Reg.exe add "HKLM\SOFTWARE\Classes\uplay" /ve /t REG_SZ /d "URL:uplay protocol" /f
Reg.exe add "HKLM\SOFTWARE\Classes\uplay" /v "URL Protocol" /t REG_SZ /d "" /f
Reg.exe add "HKLM\SOFTWARE\Classes\uplay\DefaultIcon" /ve /t REG_SZ /d "UbisoftConnect.exe" /f
Reg.exe add "HKLM\SOFTWARE\Classes\uplay\Shell\Open\Command" /ve /t REG_SZ /d "\"%~dp0UbisoftConnect.exe\" \"%%1\"" /f

set "script_dir=%~dp0"
set "shortcut_exe_path=%~dp0UbisoftConnect.exe"
set "shortcut_work_dir=%script_dir:~0,-1%"
set "shortcut_name=Ubisoft Connect"
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()"