Managing apps and software deployment through Microsoft Intune
Intune doesn’t “skip” the command – environment variables set at runtime are process‑scoped unless explicitly written to the machine or user store, and context (System vs User) also matters.
Key points from the Intune side:
- For a Win32 app, Intune runs the installer (and any script you wrap it with) in the context you configure under Install behavior (System or User). The script runs in that same context, and Intune only cares about the installer’s exit code for success/failure.
- If the installer needs the variable during setup, it must exist in that same process (or parent process) at install time.
- If the goal is to persist the variable for later use, it must be written to the machine or user environment (registry) from the same context that will later read it.
To make this reliable with Intune Win32 apps:
- Package the installer and a PowerShell script as a Win32 app using the Microsoft Win32 Content Prep Tool (
.intunewin). - Configure the Win32 app Install command to call PowerShell in 64‑bit if needed, for example:
This avoids the default 32‑bit%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File .\Install-Converge.ps1powershell.exebehavior mentioned in the Intune Win32 app program settings. - In
Install-Converge.ps1, do both:- Set the variable in the current process so the installer can see it.
- Persist it at machine level so it is available after installation.
Start-Transcript -Path 'C:\Windows\Temp\converge_install.log' -Append # 1. Make variable visible to installer process $env:RLM_LICENSE = '2765@SERVERNAME.NETWORK' # 2. Persist at machine level (System context) [Environment]::SetEnvironmentVariable('RLM_LICENSE', '2765@SERVERNAME.NETWORK', 'Machine') # 3. Run installer from same process/context Start-Process -FilePath '.\Converge5.11.exe' -ArgumentList '/S' -Wait # 4. Verify from registry view $check = [Environment]::GetEnvironmentVariable('RLM_LICENSE', 'Machine') Write-Host "RLM_LICENSE in registry after set: '$check'" Stop-Transcript - In the Win32 app properties in Intune:
- Set Install behavior to System if the app and variable must be machine‑wide.
- Ensure the detection rule is based on the app (file/registry) and not on the environment variable.
If using a batch file instead of PowerShell, call setx with the correct syntax and ensure the batch file is the actual Install command for the Win32 app so it runs in the same context as the installer. Remember that setx writes to the registry and does not affect the current process environment; the installer will not see the new value unless it is started after setx from a new process.
For more complex logic (prerequisite checks, post‑install configuration), using a PowerShell script as the installer wrapper is recommended and fully supported by Intune.
References: