Arduino IDE 2.0 RC - Silent Install

Hi,
thank you very much for all the infos! :grinning:

I managed to solve my problem with a bit of scripting (I tried with some test-users and everything works fine on multiple machines) and here below I explain how.


END RESULT:

  • The IDE is deployed locally on every machine, including the core boards arduino:avr already downloaded. :white_check_mark:

  • The user (student) can download new boards on the local machine: this will probably not be needed in our school, where only Arduino UNO/Mega are used, but it could be useful in the future. :white_check_mark:

  • The user (student) can download new libraries on his (network) profile: this is desired, since every student develops personal projects that require specific libraries, so every student already has "his" libraries installed on every PC he will log on. :white_check_mark:


STEP 1 - Software DEPLOYMENT/INSTALLATION:

  • Software Installation for all users:

START /WAIT "" MSIEXEC /i "arduino-ide_2.0.0-rc5_Windows_64bit.msi" /qn ALLUSERS=1

  • I create a hidden folder named Appdata inside C:\Program Files\arduino-ide, which can be written by everyone (it shouldn't create any security problem).
    This folder contains a "neutral" arduino-cli.yaml configuration file, whith the lines:
directories:
  data: C:\Program Files\arduino-ide\Appdata\Local\Arduino15
  downloads: C:\Program Files\arduino-ide\Appdata\Local\Arduino15\staging
  user: %USERPROFILE%\Documents\Arduino

The folder (with configuration file) is copied/created with the commands:

XCOPY "Appdata" "C:\Program Files\arduino-ide" /I/Q/H/R/K/Y/S/E
ICACLS "C:\Program Files\arduino-ide\Appdata" /t /grant Everyone:(OI)(CI)M
ATTRIB +h "C:\Program Files\arduino-ide\Appdata"
  • I finally install the core boards using this configuration file:
SET "PATH_ARDUINO_CLI=C:\Program Files\arduino-ide\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe"
SET "PATH_ARDUINO_CLI_CONFIG=C:\Program Files\arduino-ide\Appdata\arduino-cli.yaml"
START /WAIT "" "%PATH_ARDUINO_CLI%" core install arduino:avr     --config-file "%PATH_ARDUINO_CLI_CONFIG%"

STEP 2 - User Configuration WHILE STARTING THE IDE:
Every user starts now the IDE not using the created icon, but instead using a given Shortcut that links to the following BATCH file (with the Arduino Icon :smile:):

@ECHO OFF
SET "CONFIG_NAME=arduino-cli.yaml"
SET "ARDUINO_CLI=C:\Program Files\arduino-ide\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe"

SET "APPDATALOCAL_DIR=C:\Program Files\arduino-ide\Appdata"
SET "CONFIG_USER_DIR=%userprofile%\.arduinoIDE"
SET "CONFIG_USER_FILE=%CONFIG_USER_DIR%\%CONFIG_NAME%"
SET "CONFIG_BLANK_FILE=%APPDATALOCAL_DIR%\%CONFIG_NAME%"


IF NOT EXIST "%CONFIG_USER_DIR%"  MD "%CONFIG_USER_DIR%"
IF NOT EXIST "%CONFIG_USER_FILE%" XCOPY "%CONFIG_BLANK_FILE%" "%CONFIG_USER_DIR%" /I/Q/H/R/K/Y/S/E
ATTRIB +h "%CONFIG_USER_DIR%"

"%ARDUINO_CLI%" config set directories.data      "%APPDATALOCAL_DIR%\Local\Arduino15"         --config-file "%CONFIG_USER_FILE%"
"%ARDUINO_CLI%" config set directories.downloads "%APPDATALOCAL_DIR%\Local\Arduino15\staging" --config-file "%CONFIG_USER_FILE%"

START "" "C:\Program Files\arduino-ide\Arduino IDE.exe"

EXIT /B 0

This solves my "catch-22" problem: at every start of the IDE, I ensure that the current user has the correct folders set (except the sketch/library one, which defaults to %USERPROFILE%\Documents\Arduino at the first start but can then be freely modified).


So long, everything seems to work just as intended, so let's hope it will stay this way :crossed_fingers:

Thank you again, cheers!
Mattia