As a best practice, you should configure each script to log errors to a file. This is because Windows Installer does not log errors generated in the scripts. You should check these logs after the script runs for any errors that need to be addressed.
To help you determine when the error occurred, you can include the date and time in the log file.
Use the following code to specify a log file and then log an error to it.
Set LogFile=<full path of log file>
…
echo %DATE% %TIME% <text> >> %LogFile%
In the following example, when the public key token is not defined, an entry is made in the specified log file. In the log file, the date and time is written in the same line as the text, "Public key should be set in script."
set LogFile=C:\ScriptLog.txt
set PublicKeyToken=e5fd0ea4ecd37420
if not defined PublicKeyToken (
echo %DATE% %TIME% Public key should be set in script >> %LogFile%
You can also add the line exit /b 1 to a script to generate an error code for Windows Installer, which will cause it to roll back.
In the following example, if the public key token has not been defined, the script will return an error to Windows Installer, and the installer will roll back.
set LogFile=C:\ScriptLog.txt
set PublicKeyToken=e5fd0ea4ecd37420
if not defined PublicKeyToken (
echo %DATE% %TIME% Public key should be set in script >> %LogFile%
exit /b 1