clink.bat 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. @echo off
  2. rem -- Copyright (c) 2012 Martin Ridgers
  3. rem -- Portions Copyright (c) 2020-2024 Christopher Antos
  4. rem -- License: http://opensource.org/licenses/MIT
  5. setlocal enableextensions
  6. set clink_profile_arg=
  7. set clink_quiet_arg=
  8. rem -- Mimic cmd.exe's behaviour when starting from the start menu.
  9. if /i "%~1"=="startmenu" (
  10. cd /d "%userprofile%"
  11. shift
  12. )
  13. rem -- Check for the --profile option.
  14. if /i "%~1"=="--profile" (
  15. set clink_profile_arg=--profile "%~2"
  16. shift
  17. shift
  18. )
  19. rem -- Check for the --quiet option.
  20. if /i "%~1"=="--quiet" (
  21. set clink_quiet_arg= --quiet
  22. shift
  23. )
  24. rem -- If the .bat is run without any arguments, then start a cmd.exe instance.
  25. if _%1==_ (
  26. call :launch
  27. goto :end
  28. )
  29. rem -- Test for autorun.
  30. if defined CLINK_NOAUTORUN if /i "%~1"=="inject" if /i "%~2"=="--autorun" goto :end
  31. rem -- Forward to appropriate loader, and endlocal before inject tags the prompt.
  32. if /i "%processor_architecture%"=="x86" (
  33. endlocal
  34. "%~dp0\clink_x86.exe" %*
  35. ) else if /i "%processor_architecture%"=="arm64" (
  36. endlocal
  37. "%~dp0\clink_arm64.exe" %*
  38. ) else if /i "%processor_architecture%"=="amd64" (
  39. if defined processor_architew6432 (
  40. endlocal
  41. "%~dp0\clink_x86.exe" %*
  42. ) else (
  43. endlocal
  44. "%~dp0\clink_x64.exe" %*
  45. )
  46. )
  47. goto :end
  48. :launch
  49. setlocal enableextensions
  50. set WT_PROFILE_ID=
  51. set WT_SESSION=
  52. start "Clink" cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg%%clink_quiet_arg%"
  53. endlocal
  54. :end