Menu

#1247 Updating global PATH (Envar) doesn't work correctly

3.0 Series
closed
nobody
None
5
2023-06-04
2020-05-21
No

Updating PATH using EnVAR plugin doesn't work in Win 10 Pro (64bit). When long-string version of NSIS installed it doesn't hang and string is added to global path but path is not ";" separated from other paths and two ";;" are added to the beginning of path ("PATH" => ";;PATHownpath") so PATH variable doesn't work at all and must be fixed manually!

Error only seem to happen when SetHKLM is used so manipulating local path variable (less than < 1024?) works correctly. As a work-around my installed currently only sets path locally and don't attempt tp touch HKLM path variable.

EnVar::SetHKLM ; attempting modify global path doesn't work
DetailPrint "Updating PATH enviroment variable.."
EnVar::AddValue "Path" "$INSTDIR"

Discussion

  • Jason

    Jason - 2020-05-26

    Does changing $INSTDIR to a hardcoded path work? (EnVar::AddValue "Path" "C:\test")

    SetHKCU and SetHKLM only change which key is read from and written to. The string parsing is the same for both. The string length in EnVar is copied from NSIS, so if $INSTDIR is longer than the string length then it will probably fail anyway.

    Does the installer have admin privileges? (required for writing into HKLM).

    Are you creating an ansi installer or a unicode installer? I would suggest using unicode installers if you can.

    I've done a quick test on my win 10 vm and it works fine, so if you can provide a script that fails, that would be very helpful.

     
  • Miguel Barro Otero

    I believe your issue has to do with HKML and HKCU path entry lengths. A bug has been detected in EnVar original implementation concerning large registry entries.
    Check on https://github.com/GsNSIS/EnVar for an update.

     
  • Jason

    Jason - 2022-06-10

    Just to wrap this up, I rewrote the plugin to use a double-linked list to manage memory instead, which also made it easier to split and recombine the paths too.

    My plugin is only released on the NSIS wiki, any other versions are forks of my code.

     
  • Anders

    Anders - 2023-06-04
    • status: open --> closed
     

Log in to post a comment.