Home > Mobile >  Append bin folder to PATH environement variable after installation
Append bin folder to PATH environement variable after installation

Time:01-21

I have done a C program for Windows and an NSIS installer using CPack. I want that after the installation, the user can call my program from the terminal without giving the whole path of the exe.
Sometimes some installers even add an Add useful environment variables checkbox at the end of the installation to give the user a choice.

Is it possible to add to the PATH environment variable the path to our bin folder at the end of the installation using CPack and NSIS Generator?

If this is not possible, how do other programs add environment variables during installation?

CodePudding user response:

As always, check the documentation... https://cmake.org/cmake/help/latest/cpack_gen/nsis.html

CPACK_NSIS_MODIFY_PATH

   Modify PATH toggle. If this is set to ON, then an extra page will appear in the installer that will allow the user to choose whether the program directory should be added to the system PATH variable.

Note that this is hard-coded to be the $INSTDIR\bin path and is not configurable. In particular, setting CMAKE_INSTALL_BINDIR to anything other than bin will break.

  •  Tags:  
  • Related