@echo off :: Skip extension installation if none are being passed on if "%~1"=="" ( echo INFO: No arguments were passed - skipping extension installation goto :eof ) else echo INFO: Arguments were passed - extensions are being installed :: Loop through all extensions and prepend --install-extension; then set it as %allExtensions% for /f "tokens=*" %%i in ('cmd /v /c "set allExtensions= &&(@for %%a in (%*) do @set allExtensions=!allExtensions! --install-extension %%a) && echo!allExtensions!"') do set allExtensions=%%i :: Execute code command with generated args echo INFO: Executing "%ProgramW6432%\Microsoft VS Code\bin\code.cmd %allExtensions% --force" "%ProgramW6432%\Microsoft VS Code\bin\code.cmd" %allExtensions% --force