DSC and Package resource (EXE) with environment variable

I am trying to install a .exe setup package using the Package resource.

The .exe uses an environment variable during the installation and the environment variable has been set in the server image so it’s already set.
The installation won’t pick up the environment variable though.

If I run the same installation from the command prompt, it works just fine.
I also tried adding an Environment Resource to set the variable but I get the same results.

Does anyone know why the environment variables are not honored?
Perhaps it has something to do with the execution context?

We’d need some more specific information (which installer, which environment variable, do you have any logs from the installation, etc), but so far, every problem I’ve seen posted about the DSC Package resource stems from the fact that it winds up being executed as LocalSystem, and many installers don’t seem to have been developed or tested with that scenario in mind.

Hi Dave,

Thank you for your response.

The software I am trying to install is RabbitMQ and the installation runs fine and the product gets installed but if the environment variable RABBITMQ_BASE is set, certain components should be installed in the directory set as value for the variable.
The installer runs but does not pick up this variable so it uses the default path instead.

The installer is NSIS (Nullsoft Scriptable Install System) and the variable is RABBITMQ_BASE.
I am currently looking for the log files but I haven’t been able to find them yet.

Hmm… looking at the Environment resource now, I have a sneaking suspicion that it won’t take effect until the next time a process starts, because the resource is setting the value directly in the registry (and not doing anything else). If this is the case, it would be a simple matter to create a community version of the Environment resource which also sets the variable in the current process’s environment. That way, it should take effect right away when later DSC resources are applied.

I’ll play around with this at some point, when there’s time. In the meantime, I’d recommend investigating whether this installer can take command-line arguments instead of relying on environment variables.

Hi David,

Again, many thanks for the quick response. :slight_smile:
I did quite a bit of research on the command line parameter but I could not find any way to set this.

I just need to clarify two things here.

  1. I have tried to set the environment variable in our server image as well so it has been there for many reboots prior to the installation but that did not work either so it seems like the environment variables are not honored at all.
  2. The installation directory is something that I may be able to change but this is a “data” directory so only some files goes in the directory pointed to by the variable.

Since we are evaluating DSC at the moment my real interest in this is really just to know if the environment variables are honored or if this may become a possible issue in the future.

As far as I know, the only thing special about how DSC launches an installer is the fact that it’s done with the System account. If you set the environment variable for the whole machine, then the installer should see that.