Obtaining Inno Setup's installation path

From ISXKB

Jump to: navigation, search

Contents

Introduction

Inno Setup's compiler can be invoked from a command line or from a batch script. The GUI compiler requires the parameter '/cc', the command line version only requires the script's file name.

Many compilation scripts therefore contain lines like these:

"C:\Program files\Inno Setup 5\Compil32.exe" /cc script.iss

or

"C:\Program files\Inno Setup 5\ISCC.exe" script.iss

This works as long as the Inno Setup compiler is installed in 'C:\Program files\Inno Setup 5'.

But what if it's not? The compilation would fail.

Obtaining the installation path

Inno Setup's installation path is stored in the registry at 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1'. The Windows tool REG.EXE can be used to retrieve this path.

SETLOCAL
SET CompilerExe=
FOR /F "eol=; tokens=1,2* delims=	" %%a IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v InstallLocation') DO (
	SET CompilerExe=%%c
)
SET CompilerExe=%CompilerExe%ISCC.exe
ECHO %CompilerExe%.
ENDLOCAL

Note that the gap between 'delims=' and '"' must be a single TAB character.

The above script runs on Windows XP. It should be mentioned that Windows' REG command slightly differs on different versions of Windows and different resource kits. It may be required to adjust its invocation for at least Windows NT and Windows 2000. Operating systems prior to Windows NT don't include any REG command, so the batch file will not work at all.

Examples

Here's an example on how to use the script:

SETLOCAL
SET CompilerExe=
FOR /F "eol=; tokens=1,2* delims=	" %%a IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v InstallLocation') DO (
	SET CompilerExe=%%c
)
rem SET CompilerExe=%CompilerExe%Compil32.exe /cc
SET CompilerExe=%CompilerExe%ISCC.exe

"%CompilerExe%" script1.iss
"%CompilerExe%" script2.iss
"%CompilerExe%" script3.iss

ENDLOCAL

See also

External links

  • GUI = Graphical User Interface at Wikipedia
Personal tools
Ads: