Old PATH environment when my app is launched after installation by the installer

57 views
Skip to first unread message

Mateusz R.

unread,
Feb 9, 2026, 11:02:15 AM (12 days ago) Feb 9
to innosetup
Hi,

During installation, I install a component that adds a new directory to the PATH. After installation, my application runs, but it doesn't get the new PATH. It seems to inherit environment variables from the installer process.
I run the application using the following entry:
[Run]
Filename: {app}\MyApp.exe; WorkingDir: {app}; Flags: postinstall waituntilidle; Description: Run MyApp;
-----
When I run the application later, it's fine; the application has the new PATH.
-----
What should I do? Will adding the shellexec flag help?

Gavin Lambert

unread,
Feb 9, 2026, 5:18:57 PM (12 days ago) Feb 9
to innosetup
On Tuesday, February 10, 2026 at 5:02:15 AM UTC+13 Mateusz R. wrote:
During installation, I install a component that adds a new directory to the PATH. After installation, my application runs, but it doesn't get the new PATH. It seems to inherit environment variables from the installer process.
I run the application using the following entry:
[Run]
Filename: {app}\MyApp.exe; WorkingDir: {app}; Flags: postinstall waituntilidle; Description: Run MyApp;

[Setup]
ChangesEnvironment=yes

Having said that, the PATH is only supposed to be updated for things the user should run from the command line.  You should not update it if it's just for DLL loading for your app; there are better ways to do that.

Mateusz R.

unread,
Feb 12, 2026, 6:07:53 AM (10 days ago) Feb 12
to innosetup
Unfortunately, ChangesEnvironment=yes doesn't work.
The installer (InnoSetup) is running with the old PATH. During installation, the component (in my case, SQL LocalDB) modifies the PATH. When the installer finally runs MyApp.exe, the environment variables are copied from the parent process to the child process (with the old PATH value).

There's a workaround for this problem by running the application through explorer.exe.

[Run]
Filename: "explorer.exe"; Parameters: """{app}\MyApp.exe"""; WorkingDir: "{app}"; Flags: postinstall waituntilidle shellexec; Description: "Run MyApp";

or

[Run]
Filename: "{win}\explorer.exe"; Parameters: """{app}\MyApp.exe"""; WorkingDir: "{app}"; Flags: postinstall waituntilidle; Description: "Run MyApp";

I choose the second option.

Do you have any comments on this solution?
Reply all
Reply to author
Forward
0 new messages