# (Windows) Update PATH as part of install?

**URL:** <https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526>\
**Category:** Internals\
**Tags:** windows\
**Created:** [December 2, 2022, 5:57pm UTC](https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526 "2022-12-02T17:57:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [December 2, 2022, 5:57pm UTC](https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526/1 "2022-12-02T17:57:54Z")

</div>

Would it ever be possible to have the Windows installer update the system `PATH` variable to include the Racket program folder? (And, ideally, remove it again on uninstall.) This is the only really unfriendly part of setting up Racket on Windows.

I think it’s probably not feasible on Linux or Mac OS, but since there is only one place where `PATH` is managed in Windows, it seems like it should be possible in principle.

---

<div class="post-metadata">

**Author:** ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)\
**Post date:** [December 3, 2022, 11:13pm UTC](https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526/2 "2022-12-03T23:13:35Z")

</div>

Not a conclusion, but an explanation of where things stand:

There's an option in DrRacket's "Help" menu for Windows and Mac OS to update `PATH`: "Configure Command Line for Racket...". Partly, that functionality in DrRacket because there's no installer program on Mac OS.

For Windows, I think it would make sense to add support to the installer, and I would probably have done that already if it were easy. Unfortunately, the installer that we use has issues with this task; see the top of [Path Manipulation - NSIS](https://nsis.sourceforge.io/Path_Manipulation). There's a plug-in to fix the problem, but I don't think think the plug-in will work on non-Windows machines where we run cross builds. And there's an example script linked from the NSIS docs to use Win32 functionality, but the license is GPL 2, which is a complication. If someone is interested enough to work out a solution that works for cross builds, I'd be happy to help merge it to the use of NSIS in the `distro-build-client` package.

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [December 5, 2022, 3:29pm UTC](https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526/3 "2022-12-05T15:29:53Z")

</div>

> [@mflatt](#):
>
> There's an option in DrRacket's "Help" menu for Windows and Mac OS to update `PATH`: "Configure Command Line for Racket...".

I wasn’t aware of this! I tried it on Windows just now under different scenarios and it works well. Even this much is helpful, because it means giving guidance to a new user is a lot simpler, even if there is an extra step involved.

> There's a plug-in to fix the problem, but I don't think think the plug-in will work on non-Windows machines where we run cross builds. And there's an example script linked from the NSIS docs to use Win32 functionality, but the license is GPL 2, which is a complication. If someone is interested enough to work out a solution that works for cross builds, I'd be happy to help merge it to the use of NSIS in the `distro-build-client` package.

I see, yes, this is tricky. Thanks for pointing me in the right direction.

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [December 7, 2022, 5:45pm UTC](https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526/4 "2022-12-07T17:45:47Z")

</div>

> [@mflatt](#):
>
> And there's an example script linked from the NSIS docs to use Win32 functionality, but the license is GPL 2, which is a complication.

I emailed Christian Franke, the author of that script, and he explained that the `AddToPath`, `RemoveFromPath`, and `StrStr` functions in that script were all based originally on examples from the NSIS wiki (which it appears would have made them subject to the zlib/libpng license) and has no problem with us using those functions specifically under a more relaxed license.

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [December 7, 2022, 7:56pm UTC](https://racket.discourse.group/t/windows-update-path-as-part-of-install/1526/5 "2022-12-07T19:56:54Z")

</div>

To be clear, I know you have bigger fish to fry and am not expecting you to make use of this any time soon. I would also submit a PR; but it will be some time before I have a big-enough chunk of free time to delve into the package and figure out how to test my changes. Whether I eventually make the attempt or someone else does, at least we have what seems to me a feasible approach.
