Vicky
Vicky

Reputation: 17425

Setting environment variable through NSIS Envar-plugin

I have a custom installer created through NSIS.

I have the following Ant task doing the same:

<target name="buildNSIS">
    <exec executable="D:\NSIS\nsis-binary\makensis.exe" failonerror="true" >
      <!-- providing some nsis definitions -->
      <arg value="/DPROJECT_NAME=${ant.project.name}"/>
      <!-- passing the script -->
      <arg value=".\installer\MySetup.nsi"/>
    </exec>
</target>

where MySetup.nsi is the script to run through NSIS for the installer.

I want to set an environment variable as part of the install process.

I read that its best to do using: https://nsis.sourceforge.io/EnVar_plug-in

However, the instruction there is confusing. It just says: Just extract the contents to your nsis directory (usually '$PROGRAMFILES\NSIS')

What does it mean?

My D:\NSIS\nsis-binary directory looks like:

enter image description here

So do I unzip Envar_plugin.zip inside Plugins directory above and start using EnVar::AddValue or EnVar::AddValueEx functions inside my MySetup.nsi as mentioned in Envar_plugin examples?

How do I use Envar_plugin so that my resultant custom installer through MySetup.nsi for my software will set environment variables during installation of my software?

Upvotes: 2

Views: 1101

Answers (1)

Anders
Anders

Reputation: 101764

Plug-ins have to be installed in the correct plug-in subdirectory inside the NSIS folder. Some plug-ins only have a .DLL file in the root of the .ZIP file and some already have the correct directory tree in the .ZIP. This specific plug-in has the latter and you can just extract the contents to your main NSIS folder.

If you try to execute a plug-in command (name::function) and NSIS cannot find the plug-in then you most likely put the .DLL file in the wrong folder. Recent versions of NSIS will print a list of directories it tried to search when this happens.

Upvotes: 1

Related Questions