wforl
wforl

Reputation: 889

Inno Setup - Not picking up enviroment variables

I'm trying to run an Inno setup from another process, as can be seen below.

ProcessStartInfo pstart = new ProcessStartInfo(@"setup.exe");
pstart.UseShellExecute = false;
pstart.EnvironmentVariables.Add("SomeKey", "SomeValue");
Process.Start(pstart);

However, [Process] environment variables (environment variables set on the process) don't seem to be picked up. It only seems to pick up [User/Machine] environment variables.

Im using the variable as : {%SomeKey|Fallback}

And when trying to use [Process] environment variables, it always uses the fallback.

Upvotes: 0

Views: 306

Answers (1)

Miral
Miral

Reputation: 13095

Inno uses ShellExecute in order to relaunch itself with elevated permissions (when PrivilegesRequired=admin -- which is the default -- and if the installer is not already running with admin permissions). As a result of this, the parent process of the "real" installer is the shell, not your application, so it cannot inherit environment variables from it.

You should use command line parameters or a /loadinf-style response file instead.

If you desperately want the environment variables to carry through, then you can try launching it with elevated permissions yourself (possibly via a helper app). However bear in mind that doing this will disable some of the standard functionality, such as runasoriginaluser (which is used by default on postinstall [Run] entries).

Upvotes: 2

Related Questions