简体   繁体   中英

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:

在此输入图像描述

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM