Inno Setup Change Install Directory Exists

The Setup program accepts optional command line parameters. These can be useful to system administrators, and to other programs calling the Setup program.

/SP-

Inno Setup custom data directory location. In my last post, I forgot to point you to Inno Setup; go get the Inno Setup QuickStart Pack to get going. I showed how to copy a directory full of data, like tutorials or sample data, that might change depending on the customer. That means the files are not known when the installer is compiled. Inno Setup does not offer any way to let you name (or rename) the uninstaller. Inno Setup takes care of naming conflicts on its own. Also note that when you try to rename the uninstaller manually (like some answers here do), you break the reference to the uninstaller in Add or remote application in Control Panel. If the directory already exists, the compression state of any files present in the directory will not be changed. Instructs the uninstaller to always attempt to delete the directory if it's empty. Normally the uninstaller will only try to delete the directory if it didn't already exist prior to installation. 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.

Disables the This will install... Do you wish to continue? prompt at the beginning of Setup. Of course, this will have no effect if the DisableStartupPrompt[Setup] section directive was set to yes.

/SILENT, /VERYSILENT

Instructs Setup to be silent or very silent. When Setup is silent the wizard and the background window are not displayed but the installation progress window is. When a setup is very silent this installation progress window is not displayed. Everything else is normal so for example error messages during installation are displayed and the startup prompt is (if you haven't disabled it with DisableStartupPrompt or the '/SP-' command line option explained above).

If a restart is necessary and the '/NORESTART' command isn't used (see below) and Setup is silent, it will display a Reboot now? message box. If it's very silent it will reboot without asking.

/SUPPRESSMSGBOXES
Directory

Instructs Setup to suppress message boxes. Only has an effect when combined with '/SILENT' and '/VERYSILENT'.

The default response in situations where there's a choice is:

  • Yes in a 'Keep newer file?' situation.
  • No in a 'File exists, confirm overwrite.' situation.
  • Abort in Abort/Retry situations.
  • Cancel in Retry/Cancel situations.
  • Yes (=continue) in a DiskSpaceWarning/DirExists/DirDoesntExist/NoUninstallWarning/ExitSetupMessage/ConfirmUninstall situation.
  • Yes (=restart) in a FinishedRestartMessage/UninstalledAndNeedsRestart situation.

5 message boxes are not suppressible:

  • The About Setup message box.
  • The Exit Setup? message box.
  • The FileNotInDir2 message box displayed when Setup requires a new disk to be inserted and the disk was not found.
  • Any (error) message box displayed before Setup (or Uninstall) could read the command line parameters.
  • Any message box displayed by [Code] support function MsgBox.
/LOG

Causes Setup to create a log file in the user's TEMP directory detailing file installation and [Run] actions taken during the installation process. This can be a helpful debugging aid. For example, if you suspect a file isn't being replaced when you believe it should be (or vice versa), the log file will tell you if the file was really skipped, and why.

The log file is created with a unique name based on the current date. (It will not overwrite or append to existing files.)

The information contained in the log file is technical in nature and therefore not intended to be understandable by end users. Nor is it designed to be machine-parseable; the format of the file is subject to change without notice.

/LOG='filename'

Same as /LOG, except it allows you to specify a fixed path/filename to use for the log file. If a file with the specified name already exists it will be overwritten. If the file cannot be created, Setup will abort with an error message.

Change
/NOCANCEL

Prevents the user from cancelling during the installation process, by disabling the Cancel button and ignoring clicks on the close button. Useful along with '/SILENT' or '/VERYSILENT'.

/NORESTART

Instructs Setup not to reboot even if it's necessary.

/RESTARTEXITCODE=exit code

Specifies the custom exit code that Setup is to return when a restart is needed. Useful along with '/NORESTART'. Also see Setup Exit Codes.

/LOADINF='filename'

Instructs Setup to load the settings from the specified file after having checked the command line. This file can be prepared using the '/SAVEINF=' command as explained below.

Don't forget to use quotes if the filename contains spaces.

/SAVEINF='filename'

Instructs Setup to save installation settings to the specified file.

Don't forget to use quotes if the filename contains spaces.

/LANG=language

Specifies the language to use. language specifies the internal name of the language as specified in a [Languages] section entry.

When a valid /LANG parameter is used, the Select Language dialog will be suppressed.

/DIR='x:dirname'

Overrides the default directory name displayed on the Select Destination Location wizard page. A fully qualified pathname must be specified.

/GROUP='folder name'

Overrides the default folder name displayed on the Select Start Menu Folder wizard page. If the [Setup] section directive DisableProgramGroupPage was set to yes, this command line parameter is ignored.

Inno Setup Change Install Directory Exists Free

/NOICONS

Instructs Setup to initially check the Don't create a Start Menu folder check box on the Select Start Menu Folder wizard page.

/TYPE=type name

Overrides the default setup type.

If the specified type exists and isn't a custom type, then any /COMPONENTS parameter will be ignored.

/COMPONENTS='comma separated list of component names'

Overrides the default component settings. Using this command line parameter causes Setup to automatically select a custom type. If no custom type is defined, this parameter is ignored.

Only the specified components will be selected; the rest will be deselected.

If a component name is prefixed with a '*' character, any child components will be selected as well (except for those that include the dontinheritcheck flag). If a component name is prefixed with a '!' character, the component will be deselected.

Inno Setup Change Install Directory Exists

This parameter does not change the state of components that include the fixed flag.

Inno setup change install directory exists download
Deselect all components, then select the 'help' and 'plugins' components:
/COMPONENTS='help,plugins'
Deselect all components, then select a parent component and all of its children with the exception of one:
/COMPONENTS='*parent,!parentchild'
/TASKS='comma separated list of task names'

Specifies a list of tasks that should be initially selected.

Only the specified tasks will be selected; the rest will be deselected. Use the /MERGETASKS parameter instead if you want to keep the default set of tasks and only select/deselect some of them.

If a task name is prefixed with a '*' character, any child tasks will be selected as well (except for those that include the dontinheritcheck flag). If a task name is prefixed with a '!' character, the task will be deselected.

Deselect all tasks, then select the 'desktopicon' and 'fileassoc' tasks:
/TASKS='desktopicon,fileassoc'
Deselect all tasks, then select a parent task and all of its children with the exception of one:
/TASKS='*parent,!parentchild'
/MERGETASKS='comma separated list of task names'

Like the /TASKS parameter, except the specified tasks will be merged with the set of tasks that would have otherwise been selected by default.

If UsePreviousTasks is set to yes, the specified tasks will be selected/deselected after any previous tasks are restored.

Keep the default set of selected tasks, but additionally select the 'desktopicon' and 'fileassoc' tasks:
/MERGETASKS='desktopicon,fileassoc'
Keep the default set of selected tasks, but deselect the 'desktopicon' task:
/MERGETASKS='!desktopicon'
/PASSWORD=password

Specifies the password to use. If the [Setup] section directive Password was not set, this command line parameter is ignored.

When an invalid password is specified, this command line parameter is also ignored.

Skip to: Download | Installation and Usage (AutoIt) | Installation and Usage (Inno Setup) | Technical Details

Inno Setup Change Install Directory Exists Online

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

Legacy ModPath AutoIt Source (3.16 KB) - The AutoIt source code for ModPath

ChangeLog - ModPath development details

Inno

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:

  1. Copy modpath.iss to the same directory as your setup script
  2. Add this statement to your [Setup] section
    • ChangesEnvironment=true
  3. 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 the ModPathName setting below.
    • Name: modifypath; Description: Add application directory to your environmental path; Flags: unchecked
  4. 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 either system or user. 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'

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.

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.

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.

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.