1

I'm using Inno setup to build an application installer.

During the installation I am adding a registry key which provides a PATH where I will store common files (dlls etc.) which might be used by multiple different applications (or multiple versions of the same application!).

I am using the method suggested in this article: http://www.codeguru.com/cpp/w-p/dll/article.php/c99/Application-Specific-Paths-for-DLL-Loading.htm

The problem I have is that when the installation is complete, the user can auto-run the application. In this instance, the application cannot find the dlls in the PATH location. If I close the application and relaunch it from the explorer it works just fine.

I don't want to place the files in standard shared dll locations, they aren't all dlls, and I want better control of what dll versions my applications are using. Also, putting the files in the application installation .exe directory isn't an option either. I also don't want to add the PATH to the system environment path (even if I did, I suspect I would probably have the same problem anyway!)

Any ideas?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Phil B
  • 387
  • 5
  • 15
  • A case of RTFM I think!! http://www.jrsoftware.org/ishelp/index.php?topic=registrysection I've used the shellexec command in the [run] section, it seems to resolve the problem. – Phil B Apr 10 '17 at 19:17
  • What's the protocol for this? Delete question? I figure it might be useful for some other fool like me. At least I think the tip about Application Specific Paths is actually quite useful, and doesn't appear too widely referenced. – Phil B Apr 10 '17 at 19:18
  • Ye I posted the wrong link: http://www.jrsoftware.org/ishelp/index.php?topic=runsection The "shellexec" flag runs the program "the same way it would be if the user double-clicked the file in Explorer." In other words, it starts a new process, not a child of the installer process, so it picks up on the environment changes, which I guess adheres to what you put in your answer. – Phil B Apr 11 '17 at 08:35
  • I double checked it. The run command looks like `[Run] Filename: {app}\{#ExeName}.exe; Description: {cm:LaunchProgram,{#AppName}}; Flags: nowait postinstall skipifsilent` I changed the flags to `postinstall shellexec skipifsilent`, and it does run properly (finding the dlls in PATH provided in registry) – Phil B Apr 11 '17 at 09:31
  • So please, post it as an answer with an example. – Martin Prikryl Apr 11 '17 at 09:33

1 Answers1

1

Some background and my 'current' solution. Key I'm trying to add is:

[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\..\App Paths\{#ExeName}.exe"; ValueType: string; ValueData: "{app}"; Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\Microsoft\..\App Paths\{#ExeName}.exe"; ValueType: string; ValueName: "Path"; ValueData: "{#CommonPath}"; Flags: uninsdeletekey

In my [run] section I had:

Filename: {app}\{#ExeName}.exe; Description: {cm:LaunchProgram,{#AppName}}; Flags: nowait postinstall skipifsilent 

I changed the flags to:

postinstall shellexec skipifsilent

As per Inno Setup Help using the shellexec command:

The file will be opened...the same way it would be if the user double-clicked the file in Explorer.

Along the lines of Martin's answer above, I believe it works because shellexec spawns a new process which picks up the environment changes, unlike if I launch the application as a child of the installer's process.

Phil B
  • 387
  • 5
  • 15
  • I'm on windows 10, inno setup 5.5.5 if it makes any differene. I guess for now I just have to say thanks for the warning. I'll get a few people to test before going live. Hopefully I won't regret it! – Phil B Apr 11 '17 at 10:01