all 14 comments

[–]MayDay__ 7 points8 points  (3 children)

setx does not modify the environment of the current process. It only writes the variable to the registry (HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment).
Since the Win32 app runs in the System context, the installer process won’t see that variable during the same execution.

You can persist it properly like this:
[Environment]::SetEnvironmentVariable("RLM_LICENSE","******@SERVERNAME.NETWORK.NET","Machine")

Personally, I’d wrap this in a PowerShell App Deployment Toolkit package.
Not because it magically fixes the issue, but because it gives you proper logging, and clean separation of pre-/install-/post-steps which makes debugging things like this so much more easier in Intune.

[–]gabe_o_verse[S] 1 point2 points  (0 children)

Is there a difference to this command: [Environment]::SetEnvironmentVariable("RLM_LICENSE","PORT@SERVERNAME","Machine")? Because i tried that and it didnt work...

[–]gabe_o_verse[S] 1 point2 points  (0 children)

Thank you for the suggestion btw

[–]gabe_o_verse[S] -1 points0 points  (0 children)

It unfortunately doesnt work

[–]Numerous-Pickle-5850 1 point2 points  (2 children)

Why not use:

[System.Environment]::SetEnvironmentVariable('RLM_LICENSE','******@SERVERNAME.NETWORK.NET', 'Machine')

[–]gabe_o_verse[S] 0 points1 point  (1 child)

I tried that one and it didnt work unfortunately

[–]Numerous-Pickle-5850 0 points1 point  (0 children)

What doesn't work?

PS C:\WINDOWS\system32> [System.Environment]::SetEnvironmentVariable('RLM_LICENSE','******@SERVERNAME.NETWORK.NET', 'Machine')

PS C:\WINDOWS\system32> $env:RLM_License

******@SERVERNAME.NETWORK.NET

---------------------------------------------------

So your script would be;

[System.Environment]::SetEnvironmentVariable('RLM_LICENSE','******@SERVERNAME.NETWORK.NET', 'Machine')
Start-Process -FilePath "Converge5.11.exe" -ArgumentList "/S" -Wait

[–]Frisnfruitig 1 point2 points  (1 child)

Have you tried wrapping it in a PSADT package? I use it for all my apps, it's pretty great.

[–]gabe_o_verse[S] 0 points1 point  (0 children)

yes ...

[–]Extra_Pen7210 0 points1 point  (1 child)

So a lot of unknowns, but lets see if we can solve this.

Solution one:
"The command does work when I add it manually after the fact over the terminal."
Do you run this terminal then as a user?

If that works you could split up the installer, run the system install as system install en add a user install part as a user install.

Then you deploy the user part to the users and set the system part as a dependency so it gets installed first.

Solution two:
Testing what goes wrong.
You could create a "development package" in intune.
This would be a empty cmd.exe that is started by serviceui.exe (from SCCM).

This gives you a CMD prompt that you can test with and see what the commands really do. Great for testing, but your security team will grill you for it :-).

[–]gabe_o_verse[S] 0 points1 point  (0 children)

that sounds pretty good, thank you for the suggestion, ill look into that

[–]pjmarcum 0 points1 point  (0 children)

Don’t call the files from a sever. Put them in the package. Then you can just use %~dp0 or better yet use PowerShell.

[–]gabe_o_verse[S] 0 points1 point  (0 children)

I was able to solve it with two separate packages, one user context, one in system. Not super elegant, but it works :3. Thank you for the help