Can Innosetup add the program folder to Windows path?

1,542 views
Skip to first unread message

Leo D

unread,
Jun 15, 2021, 9:06:28 AM6/15/21
to innosetup
Hi,
I've just tried Innosetup bu I could not find this option. For my program to work correctly the folder where it is installed should be added to the Path environmental variable. Is there a way to include that in the project script?

DJCarlos

unread,
Jun 15, 2021, 9:09:48 AM6/15/21
to inno...@googlegroups.com
You can set it via the registry [registry] or you could set a CMD prompt to SET X


On Tue, Jun 15, 2021 at 2:06 PM Leo D <doro...@gmail.com> wrote:
Hi,
I've just tried Innosetup bu I could not find this option. For my program to work correctly the folder where it is installed should be added to the Path environmental variable. Is there a way to include that in the project script?

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/330915aa-117a-4d59-90b3-59a386a52b5cn%40googlegroups.com.

Bill Stewart

unread,
Jun 15, 2021, 4:32:48 PM6/15/21
to innosetup
On Tuesday, June 15, 2021 at 7:06:28 AM UTC-6 doro...@gmail.com wrote:

I've just tried Innosetup bu I could not find this option. For my program to work correctly the folder where it is installed should be added to the Path environmental variable. Is there a way to include that in the project script?

There's no built-in Inno Setup functionality to update the Path variable, but you can use a DLL I wrote called PathMgr.dll:


There is a sample .iss file that demonstrates how to use the DLL.

Gavin Lambert

unread,
Jun 15, 2021, 6:48:00 PM6/15/21
to inno...@googlegroups.com
Bear in mind that the only good reason to add your directory to the PATH
is if you are installing apps that are intended to be run directly by
the user in a Command Prompt. (And even then, in some cases it's better
to install a shortcut that opens a new Command Prompt with the PATH
temporarily set rather than to set it permanently.)

If you're doing it for some other reason, then there's probably a better
way to do it that doesn't need the PATH to be set.

Lev Dorosinskiy

unread,
Jun 16, 2021, 4:11:29 AM6/16/21
to inno...@googlegroups.com
Thank you guys for your suggestions. SETX via CMD prompt seems to be the easiest but I could not manage to make it work correctly. I guess, I could not figure out the right syntax for the quotes ". The cmd comand should be: setx path "%path%;{app}" and, I guess, I should use [Run], so the string should look like:
[Run]
Filename: "cmd.exe"; Parameters: "/c setx path "%path%;{app}""
There are nested quotes here. According the Help this is the correct way, however the compiler displays an error. I tried to remove the inner quotes. Then the error disappeared but the code does not work as needed - the folder does not get added to the Path.
Can you please help me to compose this string correctly. I am new to Inno Setup, in fact, I am trying it just for this purpose, otherwise my program does not require an installer. So I have no experience with it.

You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/CS3uzYs_zi8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/CAG%2B%2B0n4nW8EqO82a79ek2tWQRjO8wjBW%3DDdtTWW93KaiRF6Meg%40mail.gmail.com.

Bill Stewart

unread,
Jun 16, 2021, 12:01:41 PM6/16/21
to innosetup
On Wednesday, June 16, 2021 at 2:11:29 AM UTC-6 doro...@gmail.com wrote:

Thank you guys for your suggestions. SETX via CMD prompt seems to be the easiest but I could not manage to make it work correctly. I guess, I could not figure out the right syntax for the quotes ". The cmd comand should be: setx path "%path%;{app}" and, I guess, I should use [Run], so the string should look like:
[Run]
Filename: "cmd.exe"; Parameters: "/c setx path "%path%;{app}""
There are nested quotes here. According the Help this is the correct way, however the compiler displays an error. I tried to remove the inner quotes. Then the error disappeared but the code does not work as needed - the folder does not get added to the Path.
Can you please help me to compose this string correctly. I am new to Inno Setup, in fact, I am trying it just for this purpose, otherwise my program does not require an installer. So I have no experience with it.
 
First, I concur with Gavin Lambert's comments. Are you really sure you need to add something to the Path?

Second, I wouldn't recommend blindly using setx.exe because it isn't built specifically to manage the Path environment variable (which consists of a semicolon-delimited list of directory names).

Sample questions that illustrate what I mean:

1) What happens when you uninstall? Is your directory removed from the Path?
2) What happens if you reinstall, upgrade, or downgrade? Does your installer add the directory to the Path a second time?

I would recommend PathMgr.dll[1] because it handles these complexities for you automatically.

Reply all
Reply to author
Forward
0 new messages