ArduinoIDE 2.3.6 silent with libs for all users

Hello!

I need to distribute ArduinoIDE 2.3.6 silently via SCCM to our Computer Labs at the uni.

I've managed to make a powershell script that installs the application, boards, libs, drivers and certs silent.

As default, boards and libs are installed in the userprofile folder. I need them installed for all users though. And I've managed to get boards and libs to install for all users. But when starting ArduinoIDE it only sees the installed boards, not the libs.

Help appreciated.

Hi @balterz.

Please provide a detailed description of what you did to accomplish that. That information will allow us to better understand the reason for the problem you are encountering, and the best way to proceed to solve the problem.

Here is my current code.

$ErrorActionPreference = "Stop"

# --- Variables ---
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition
$ideMsi = Join-Path $scriptRoot "Installer\arduino-ide_2.3.6_Windows_64bit.msi"
$cliMsi = Join-Path $scriptRoot "Installer\arduino-cli_1.2.2_Windows_64bit.msi"
$cliExe = "C:\Program Files\Arduino CLI\arduino-cli.exe"
$globalArduinoDir = "C:\ProgramData\ArduinoData"
$configPath = Join-Path $globalArduinoDir "arduino-cli.yaml"
$logFile = Join-Path $globalArduinoDir "install-log.txt"

# --- Ensure the global ArduinoData directory exists BEFORE logging ---
if (-Not (Test-Path $globalArduinoDir)) {
    New-Item -ItemType Directory -Path $globalArduinoDir -Force | Out-Null
}

# --- Logging Helper ---
function Log {
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    "$timestamp`t$($args -join ' ')" | Out-File -FilePath $logFile -Append -Encoding UTF8
}

Log "Starting Arduino IDE and CLI installation."

# --- Setup ---
Log "Starting Arduino IDE and CLI installation."
New-Item -ItemType Directory -Path $globalArduinoDir -Force | Out-Null

# --- Install IDE ---
Log "Installing Arduino IDE..."
Start-Process msiexec.exe -ArgumentList "/i `"$ideMsi`" /quiet /norestart ALLUSERS=1 REBOOT=ReallySuppress" -Wait

# --- Install CLI ---
Log "Installing Arduino CLI..."
Start-Process msiexec.exe -ArgumentList "/i `"$cliMsi`" /quiet /norestart ALLUSERS=1 REBOOT=ReallySuppress" -Wait

# --- Set permissions and env variable ---
Log "Granting Users full control over $globalArduinoDir"
icacls $globalArduinoDir /grant "Users:(OI)(CI)F" /T | Out-Null

Log "Setting ARDUINO_DATA_DIR system-wide"
[Environment]::SetEnvironmentVariable("ARDUINO_DATA_DIR", $globalArduinoDir, "Machine")

# --- Write CLI config ---
Log "Writing global CLI config..."
@"
directories:
  user: $globalArduinoDir
"@ | Set-Content -Path $configPath -Encoding UTF8

# Install certificates if available
$certPath = Join-Path $scriptRoot "Installer\Cert"
if (Test-Path $certPath) {
    Get-ChildItem -Path $certPath -Filter *.cer -Recurse | ForEach-Object {
        Log "Installing certificate: $($_.FullName)"
        certutil.exe -addstore -enterprise -f "TrustedPublisher" "$($_.FullName)" | Out-Null
        certutil.exe -addstore -enterprise -f "Root" "$($_.FullName)" | Out-Null
    }
} else {
    Log "No certificates found at $certPath"
}

# --- Update boards and install ---
Log "Updating board index..."
& $cliExe core update-index --config-file $configPath

$boards = @(
    "arduino:avr",
    "arduino:mbed_nano",
    "arduino:mbed_nicla",
    "arduino:mbed_opta",
    "arduino:mbed_portenta",
    "arduino:renesas_portenta",
    "arduino:renesas_uno",
    "arduino:mbed"
    # Add more if needed
)

foreach ($board in $boards) {
    Log "Installing board: $board"
    & $cliExe core install $board --config-file $configPath
}

$libs = @(
    "ArduinoBLE",
    "Arduino_LSM6DSOX",
    "WiFiNINA",
    "Adafruit TensorFlow Lite",
    "Arduino_LSM9DS1",
    "Arduino_LPS22HB",
    "Arduino_APDS9960",
    "Arduino_HTS221",
    "Ethernet",
    "Firmata",
    "Keyboard",
    "LiquidCrystal",
    "Stepper",
    "TFT",
    "Arduino_BuiltIn",
    "Servo",
    "Mouse",
    "SD"
    # Add more if needed
)

foreach ($lib in $libs) {
    Log "Installing library: $lib"
    & $cliExe lib install "$lib" --config-file $configPath
}

# --- Configure per-user ---
Log "Configuring all user profiles..."
$userProfiles = Get-ChildItem 'C:\Users' | Where-Object { Test-Path "$($_.FullName)\AppData\Roaming" }

foreach ($profile in $userProfiles) {
    $userArduinoDir = "$($profile.FullName)\AppData\Roaming\Arduino15"
    $userConfig = Join-Path $userArduinoDir "arduino-cli.yaml"
    if (-Not (Test-Path $userArduinoDir)) {
        New-Item -ItemType Directory -Path $userArduinoDir -Force | Out-Null
    }
    @"
directories:
  user: $globalArduinoDir
"@ | Set-Content -Path $userConfig -Encoding UTF8
    Log "Configured: $userConfig"
}

# Remove public desktop shortcut
$shortcutPath = "$env:Public\Desktop\Arduino IDE.lnk"
if (Test-Path -Path $shortcutPath -PathType Leaf) {
    Log "Removing desktop shortcut: $shortcutPath"
    Remove-Item "$shortcutPath" -Force
}

Log "Finished Arduino IDE and CLI installation."

OK, great. That information makes the situation clear.

This has no effect. The reason is that Arduino IDE always uses the Arduino CLI configuration file that is located at $Env:HOMEDRIVE$Env:HOMEPATH\.arduinoIDE\arduino-cli.yaml. So, although the file you created at C:\ProgramData\ArduinoData\arduino-cli.yaml is used when you run arduino-cli commands directly, it is completely ignored when using Arduino IDE.

I submitted a request to allow the user to set a custom location for the Arduino CLI configuration file used by Arduino IDE:

If you have a GitHub account, you can subscribe to that thread to get notifications of any new developments related to this subject:


:red_exclamation_mark: Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.


For now, you have two options for configuring the location of the Arduino sketchbook folder (which is referred to as the "user directory" by Arduino CLI):

  • Make your custom configuration of directories.user in the Arduino CLI configuration file that is actually used by Arduino IDE ($Env:HOMEDRIVE$Env:HOMEPATH\.arduinoIDE\arduino-cli.yaml).
  • Use the ARDUINO_DIRECTORIES_USER environment variable, just as you are already doing with the ARDUINO_DATA_DIR environment variable.

FYI, the canonical environment variable is ARDUINO_DIRECTORIES_DATA. The ARDUINO_DATA_DIR variable you are using is legacy from a very old version of Arduino CLI. Arduino CLI does still recognize the ARDUINO_DATA_DIR variable for backwards compatibility, but I recommend using the canonical configuration environment variables as specified in the documentation as it is possible that support for these old variables could be lost at some point in the future.