Skip to: Download | Installation and Usage (AutoIt) | Installation and Usage (Inno Setup) | Technical Details
Here by Inno setup using the 'deletekey' flag. WORKS PERFECTLY 7-14-06! REGISTRY; DELETE THE EXISTING VERSION 3.0 KEY and 3.1 key or 3.2 key; deletekey; When this flag is specified, Setup will first try deleting the entire key if it exists,; including all values and subkeys in it. If ValueType is not none, it will then; create a new key. Specifies additional attributes for the directory. This can include one or more of the following: readonly, hidden, system. If this parameter is not specified, Setup does not assign any special attributes to the directory. If the directory already exists, the specified attributes will be combined with the directory's existing attributes. Specifies additional attributes for the directory. This can include one or more of the following: readonly, hidden, system. If this parameter is not specified, Setup does not assign any special attributes to the directory. If the directory already exists, the specified attributes will be combined with the directory's existing attributes.
Introduction
Modify Path is a fairly simple Windows script that allows users to easily modify the path environment variable by adding a new or removing an existing directory. It was written to facilitate installation of Inno Setup packages that require path changes. As such, it is likely to be more useful for developers and administrators than end-users.
Note: I've rewritten Modify Path in native Inno Setup Pascal script. Since this was my primary use for Modify Path, I'll likely only update the Pascal script going forward. However, feel free to e-mail me if you have a need for an updated AutoIt script as well. I'll be happy to assist if I'm able.
Download Current Version: 1.4.2, Released: 04/21/2012
ModPath Inno Setup Source (6.79 KB) - This is the Inno Setup Pascal script source. An example installer package script is also available.
Legacy ModPath AutoIt Binary (119 KB) - This is the compiled AutoIt ModPath executable
Inno Setup Change Install Directory Exists Online
Legacy ModPath AutoIt Source (3.16 KB) - The AutoIt source code for ModPath
ChangeLog - ModPath development details
Install Directory Location
Requirements
- Inno Setup
- version 5.4.0 or greater
- License
- GNU Lesser General Public License (LGPL), version 3
Installation and Usage (Inno Setup)
To use ModPath in your Inno Setup package, follow these steps:
- Copy modpath.iss to the same directory as your setup script
- Add this statement to your
[Setup]
section ChangesEnvironment=true
- Add this statement to your
[Tasks]
section; You can change the Description or Flags. You can also change the Name (as of version 1.4), but it must match theModPathName
setting below. Name: modifypath; Description: Add application directory to your environmental path; Flags: unchecked
- Add the following to the end of your
[Code]
section;ModPathName
defines the name of the task defined above.ModPathType
defines whether the user or system path will be modified; this must be eithersystem
oruser
.setArrayLength
must specify the total number of dirs to be added;Result[0]
contains first directory,Result[1]
contains second (optional), etc. const
ModPathName = 'modifypath';
ModPathType = 'user';
function ModPathDir(): TArrayOfString;
begin
setArrayLength(Result, 1)
Result[0] := ExpandConstant('{app}');
end;
#include 'modpath.iss'
Once the above statements have been included and compiled into your package, the environmental path will be automatically updated with the main application directory upon installation and uninstallation if the modifypath task is enabled.
Legacy Installation and Usage (AutoIt)
ModPath has no installation process, per se. If you want to use the AutoIt script on your system, simply download it to any folder in your default system path. C:WINNT
or C:WINDOWS
(whichever is appropriate) is usually a good choice.
Usage of the program should be very straightforward. The syntax for ModPath is modpath.exe {/add | /del} <path>
. This states that modpath.exe
should be called, told whether to add a new directory to or remove an existing directory from the current path, then given the location of the new directory. Be sure to enclose the location in quotes if it contains a space.
For example, the following command will add the 'New Application' directory to the system path:modpath.exe /add 'C:Program FilesNew Application'
Inno Setup Change Install Directory Exists 2017
Conversely, the next command will remove the same directory if it already exists in the path:modpath.exe /del 'C:Program FilesNew Application'
Technical Details
Note: The following description was written for the AutoIt version of ModPath, but it also applies to the Inno Setup version.
ModPath will add or remove the specified directory to the path under both Windows 9x and NT (in the context, NT refers to any NT-based version of Windows, including 2000 and XP). However, removal support is somewhat limited under Windows 9x. ModPath can be used to remove any directory currently in the environmental path from Windows NT, but it can only remove directories that it had previously added itself from Windows 9x. This is because Windows 9x provides multiple methods of setting the path, which makes it difficult to account for every possibility.
Inno Setup Change Install Directory Exists And Is Not Empty
Under Windows NT, the system path is stored as a semi-colon delimited list in the registry key HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment[Path]
, and the user path is stored in the same format under HKEY_CURRENT_USEREnvironment[Path]
. When run, ModPath tokenizes the appropriate path into an array, and loops through each entry. If adding a directory and it already exists, it simply exists; otherwise, it appends it to the end of the current path. If removing a directory, it deletes any existing matching entries. It then writes the new key back to the registy. The updated path will take effect immediately in all newly-spawned shells.
Inno Setup Change Install Directory Exists Free
Under Windows 9x, ModPath uses C:autoexec.bat
to store the path. If adding a directory, it searches through autoexec.bat
to first check if it already exists. If adding a directory and already exists, it simply; exists; otherwise, it adds a new line appending the directory to the existing path. If removing a directory, it deletes any previously added lines to autoexec.bat
that match the specified directory.
Inno Setup Directory Exists
Path changes take effect immediately under Windows NT, but require a reboot under Windows 9x. A workaround for Windows 9x is to use the winset.exe
utility (found on any Windows 98 CD-ROM). This utility can be used to set the path for all future processes, though it doesn't modify the currently running explorer.exe, nor does it permanently set the path. It makes a good compliment to ModPath when used during an installation.