@echo off
title Add UltiMaker Cura Desktop Shortcut

echo.
echo  ============================================
echo   UltiMaker Cura  --  Desktop Shortcut Tool
echo  ============================================
echo.
echo  Checking for UltiMaker Cura on this computer...
echo.

set "CURA_EXE=C:\Program Files\UltiMaker Cura 5.12.0\UltiMaker-Cura.exe"

if not exist "%CURA_EXE%" goto :not_installed

echo  Found Cura!  Creating your desktop shortcut...
echo.

set "SHORTCUT=%USERPROFILE%\Desktop\UltiMaker Cura.lnk"

powershell -NoProfile -Command ^
  "$s = (New-Object -ComObject WScript.Shell).CreateShortcut('%SHORTCUT%');" ^
  "$s.TargetPath = '%CURA_EXE%';" ^
  "$s.WorkingDirectory = 'C:\Program Files\UltiMaker Cura 5.12.0';" ^
  "$s.Description = 'Open UltiMaker Cura 3D Printing Software';" ^
  "$s.IconLocation = '%CURA_EXE%,0';" ^
  "$s.Save()"

if not exist "%SHORTCUT%" goto :failed

echo  +-------------------------------------------------+
echo  ^|   SUCCESS!  Your shortcut is ready!            ^|
echo  +-------------------------------------------------+
echo.
echo  Look for "UltiMaker Cura" on your desktop
echo  after you close this window.
echo.
goto :done

:not_installed
echo  +-------------------------------------------------+
echo  ^|   Cura does not appear to be installed yet.    ^|
echo  +-------------------------------------------------+
echo.
echo  The shortcut cannot be created until Cura is installed.
echo  Please ask your teacher or the IT help desk for help.
echo.
goto :done

:failed
echo  +-----------------------------------------------+
echo  ^|   Something went wrong -- shortcut not saved. ^|
echo  +-----------------------------------------------+
echo.
echo  Please let your teacher know this didn't work.
echo.

:done
echo  Press any key to close this window...
pause > nul
