Originally coded by Jason Ross aka JasonFriday13 on the forums.
The original code was downloaded from the NSIS Wiki.
This plugin manages environment variables. It allows checking for environment variables, checking for paths in those variables, adding paths to variables, removing paths from variables, removing variables from the environment, and updating the installer enviroment from the registry. This plugin is provided with 32bit ansi and unicode versions, as well as a 64bit unicode version.
There are eight functions in this plugin. Returns an error code on the stack (unless noted otherwise), see below for the codes.
Constant | Code | Description |
---|---|---|
ERR_SUCCESS | 0 | Function completed successfully. |
ERR_NOREAD | 1 | Function couldn't read from the environment. |
ERR_NOVARIABLE | 2 | Variable doesn't exist in the current environment. |
ERR_NOVALUE | 3 | Value doesn't exist in the Variable. |
ERR_NOWRITE | 4 | Function can't write to the current environment. |
These functions do not return a value on the stack.
Checks for a Path in the specified VariableName. Passing "null" as a Path makes it check for the existance of VariableName. Passing "null" for both makes it check for write access to the current environment.
Adds a Path to the specified VariableName. Does does not modify existing variables if they are not the right type. AddValueEx is for expandable paths, ie %tempdir%. Both functions respect expandable variables, so if the variable already exists, they try to leave it intact. AddValueEx converts the variable to its expandable version. If the path already exists, it returns a success error code.
Deletes a path from a variable if it's the right type. The delete is also recursive, so if it finds multiple paths, all of them are deleted as well.
Deletes a variable from the environment. Note that "path" cannot be deleted. Also, variables that aren't the right type are not deleted.
Updates the installer environment by reading VariableName from the registry and can use RegRoot to specify from which root it reads from: HKCU for the current user, and HKLM for the local machine. Anything else (including an empty string) for RegRoot means it reads from both roots, appends the paths together, and updates the installer environment. This function is not affected by EnVar::SetHKCU and EnVar::SetHKLM, and does not write to the registry.
For a example NSIS script visit Docs/example.nsi.
Run the following command in your PowerShell:
Install-Module -Name Invoke-MsBuild -Force
All build and deploy actions are implemented in a PowerShell build script.
Run help Bin\Build
to get a detailed description of the available steps.
For a normal build and deploy run simply call the script without any parameters.
This project is released under the terms of the zlib License