Custom Installation Of Software From Command Prompt

Mostly this is the requirement for silent installation, changing the default installation location, for example from "Program Files" folder to somewhere else.

Introduction

Microsoft provide us a good option to install software from command prompt as well and even with various setup options. There are two dedicated utility EXEs for this purpose, one is for local installations (MsiExec.exe) and another is to install on remote using telnet.

Background

When a .msi installer is created, developer do define some hard-code properties. Here, it can be noted that different software vendors may use different property name for the same kind of information. For example, a software vendor 'ABC technology' may be using USERID & PASSWORD and for the same kind of information, another vendor 'PQR softwares' may be using USERNAME & USERPASSWORD property names. Value of these properties are supposed to be taken while installation.

Command prompt installation is sought when a custom installation is required like the following,
  • Custom level of setup interaction (ex.-Silent installation)
  • Installation on different folder than by-default program folders like "Program Files" or "ProgramFiles (x86)"

The Solution

We can install software from command prompt in the following ways:

  • Directly using Setup.exe OR Setup.msi  file + required command line parameters
  • Using MsiExec.exe for these Setup files + required command line parameters

We know that Microsoft Windows uses standard folder-tree practices to maintain programs. It has predefined locations like Program Files, Temp, AppData and so on. Generally setup files are created as per the requirement of software, and may or may not depend upon the user inputs. Installation process, popups some custom-dialog-boxes to take user inputs like license key, username, password, etc. This is known as Custom-Action. During software installation, you may have noticed that some inputs are already filled with default values (ex.- setup location: C:\Program Files\<ApplicationName>". These default values are either hardcoded or created with help of Windows predefined standard variables. Windows maintain default values with help of static system variables and Registry settings. (you may have tried %ProgramFiles%, %Tmp%, %AppData%  etc. from run window).

Captured setup input values (no matter, by-default or custom) are internally assigned to predefined properties. These predefined properties are called Property-collections and were declared by the software installation/setup writer (developer). It is noted here, that only accessible properties values are set through Custom-Action and not all.

Examples:

In my examples, I am using a CDAC's Hindi Typing learning software setup. 

Exercise 1: Install this Hindi typing software from command line.

C:\>CDACTTHN.msi

Exercise 2: Install and generate a log file which list all properties set during installation.

We can see the list of all properties used for a particular setup.msi

C:\>CDACTTHN.msi /l* 123log.txt

This command will list all the Properties like below:
silent install and change default installation location from command prompt

Exercise 3: Do a typical install silently (no user interaction),

C:\>CDACTTHN.msi /q

Exercise 4: Do a typical install silently but on a custom location/path,

C:\>CDACTTHN.msi /q INSTALLPATH=”c:\TestLocation”

Exercise 5: Install using MSIEXEC, silently and on custom location,

C:\>MSIEXEC  /a CDACTTHN.msi  TARGETDIR=c:\TestLocation\  /qn

Note:

  • On some machines, TARGETDIR may not be effective, in that case you can try TARGETDIR  or INSTALLPATH
  • In an InstallScript MSI project, the InstallScript variable MSI_TARGETDIR stores the target of an administrative installation.
There are many properties used in the installation with MSIEXEC.exe, like:
  • INSTALLPATH
  • INSTALLDIR
  • TARGETDIR
  • INSTALLFOLDER
  • INSTALLLEVEL
  • FEATURE_C_INSTALL
  • and so on

See also:


Similar Articles