HttpWatch can be installed from batch files, on the command line or from automated tools like SMS by supplying command line arguments to the setup program:
httpwatchpro.exe /S [/all-users=0|1] [/errorpath=...] [/license=...] [/ChromeExtension=0|1] [/EdgeExtension=0|1] [/D=<directory>]
In silent mode, /all-users=0 selects installation for the current user only and /all-users=1 selects installation for all users on the machine. Installing for the current user only is the default when the option is omitted. A silent install for all users must already be running elevated. When the installer runs as Local System, it installs for all users even if the option is omitted or set to 0.
An installation for the current user does need administrator rights in one case: when an existing installation for all users on the machine has to be removed first. Because a silent install cannot display a UAC prompt, Setup stops with exit code 5 instead. Run the command from an elevated command prompt in that situation.
The command line options are shown below:
The names of the command line flags are case sensitive
|
/S |
This causes the setup program to run with no GUI and to require no interaction, i.e. Silent Mode install |
|
/all-users=0|1 |
In silent and internal continuation runs, 0 selects installation for the current user only and 1 selects installation for all users. A silent installation for all users must run from an elevated command prompt. In a normal interactive run, 1 displays the Install Mode page, but detected installation state controls the initial selection and the user must choose installation for all users. When Setup runs as Local System, an absent value or 0 is overridden to install for all users on the machine. |
|
/errorpath |
This specifies where the httpwatch_error.txt file containing error information should be written. If this option is not specified the file will be written to the directory containing the setup program. The directory must already exist and be writable. Example: /errorpath=c:\temp "/errorpath=c:\temp\error logs" If the path error file contains spaces use double quotes around the whole argument not just the value |
|
/ChromeExtension=0|1 |
Disables or enables the HttpWatch extension in Google Chrome. When omitted, a fresh installation defaults to enabled. |
|
/EdgeExtension=0|1 |
Disables or enables the HttpWatch extension in Microsoft Edge. When omitted, a fresh installation defaults to enabled. |
|
/license |
This sets the file name of the HttpWatch Professional edition license. Use the value '[installed]' to use an existing, installed license. Here are some examples:
/license=httpwatch.lic /license=D:\temp\httpwatch.lic /license=\\server1\share1\httpwatch.lic /license=[installed] "/license=D:\temp\folder name with space\httpwatch.lic" If the path or file name to the license file contains spaces use double quotes around the whole argument not just the value A silent install of HttpWatch Professional requires this option. If it is omitted, Setup stops with exit code 87. |
|
/D |
The default install directory can be changed using this flag. e.g. /D=c:\program files\networktools\httpwatch If the /D argument is used then it must be the last argument on the command line and must not contain double quotes even if the destination folder contains spaces. |
Silent installation for the current user only (no administrator rights required). Run this under the user account for which HttpWatch is being installed, not under Local System:
start /wait httpwatchpro.exe /S /license=[installed]
Silent installation for all users on a machine (must be run from an elevated command prompt):
start /wait httpwatchpro.exe /S /all-users=1 "/license=C:\Deploy\HttpWatch.lic" /D=C:\Program Files\HttpWatch
When Setup is running under the Windows Local System account, it always installs for all users. The /all-users setting is ignored in this case, but always behaves as if /all-users=1 was specified. This is because the Local System account has no user profile in which HttpWatch could be installed.
Silent deployment under Local System. The installation is automatically for all users on the machine, so /all-users=1 is not required:
start /wait httpwatchpro.exe /S "/license=C:\Deploy\HttpWatch.lic" /D=C:\Program Files\HttpWatch
The HttpWatch uninstaller supports the /S flag for silent operation. The /all-users flag must match the mode that was used when HttpWatch was originally installed. The Local System override described above applies to installation by Setup, not to uninstall mode selection.
Silent uninstall of an installation for the current user:
start /wait uninstall.exe /S /all-users=0
Silent uninstall of an installation for all users on a machine (must be run from an elevated command prompt):
start /wait uninstall.exe /S /all-users=1
The uninstaller reports failures using the same exit codes as Setup, described in Detecting Errors below. An uninstall of an installation for all users that is not run from an elevated command prompt returns 5, and files that are still in use return 32.
If an error occurs during a silent install no message box or dialogs are displayed. The setup program returns a non zero exit code and writes the reason to a file called httpwatch_error.txt, for example when the destination directory is not writable.
The directory, in which this file is written, can be controlled using the /errorpath command line flag. When the setup program completes successfully it will have an exit code of zero and no error file is written. Any error file left by an earlier silent install is deleted at the start of each silent run, so the presence of httpwatch_error.txt always refers to the run that has just finished.
The uninstaller does not write an error file. A script that performs a silent uninstall should check its exit code.
The exit codes are listed below, followed by a batch file that installs HttpWatch and reports what went wrong if it did not succeed.
Setup and the uninstaller return the following exit codes. The values match the equivalent Windows system error codes, so a deployment script can test for a particular cause without reading httpwatch_error.txt:
|
0 |
Completed successfully. |
|
2 |
The operation failed for a reason not covered by the other codes below, for example the destination directory could not be written, a component could not be registered or unregistered, or a license could not be validated. |
|
5 |
Administrator rights are required but the command was not run from an elevated command prompt. |
|
32 |
One or more HttpWatch files were in use. Close all HttpWatch windows and help files, then run the command again. |
|
87 |
The command line was not valid or was incomplete, for example a silent install of HttpWatch Professional without the /license option. |
Earlier versions of HttpWatch returned exit code 2 for every failure. A script that only tests for a zero or non zero exit code needs no changes. A script that tests specifically for 2 should be updated to treat 5, 32 and 87 as failures too.
This batch file installs HttpWatch Professional silently, waits for it to finish and reports the reason if it failed. It expects the setup program and the license file to be in the same folder as the batch file itself:
@echo off setlocal rem start /wait is required so that the batch file waits for Setup to finish. rem The empty "" is the window title, which start expects when the command rem that follows it is enclosed in quotes. start "" /wait "%~dp0httpwatchpro.exe" /S "/license=%~dp0HttpWatch.lic" "/errorpath=%TEMP%" set EXITCODE=%ERRORLEVEL% if %EXITCODE% equ 0 goto installed if %EXITCODE% equ 5 goto needsadmin if %EXITCODE% equ 32 goto filesinuse if %EXITCODE% equ 87 goto badcommandline goto otherfailure :installed echo HttpWatch was installed successfully. exit /b 0 :needsadmin echo Run this batch file from an elevated command prompt. goto reporterror :filesinuse echo Close all HttpWatch windows and help files, then run this again. goto reporterror :badcommandline echo The Setup command line is not valid or is incomplete. goto reporterror :otherfailure echo HttpWatch Setup failed with exit code %EXITCODE%. goto reporterror :reporterror if exist "%TEMP%\httpwatch_error.txt" type "%TEMP%\httpwatch_error.txt" exit /b %EXITCODE%
Compare the exit code using if %ERRORLEVEL% equ as shown above. The older if errorlevel form is true for the number given or any higher number, so if errorlevel 5 would also be taken as true for 32 and 87 and would report the wrong cause.
The same pattern can be used for a silent uninstall. Replace the start line with the uninstall command and the matching /all-users flag, and remember that the uninstaller does not write an error file, so its exit code is the only result to check.
When HttpWatch is being updated or removed and one of its files is still in use, an interactive install offers the choice of retrying or of restarting Windows to complete the operation. A silent install cannot ask, and cannot continue automatically after a restart.
A silent install or uninstall therefore stops immediately with exit code 32 and does not schedule any work for the next restart. Nothing is left queued in the Windows pending file operations, so restarting the computer afterwards will not delete or replace HttpWatch files. Close the applications that are holding the files open and run the original command again.
Earlier versions could write a httpwatch_reboot.txt file to indicate that a restart was needed to complete a silent install. A silent install no longer completes with a restart pending, so this file is never created. A script that checks for it should test for exit code 32 instead. Any stale copy left by an earlier version is deleted at the start of a silent run.
To run directly from the command line or in a batch file, you will need to use the Windows Start command to wait for the setup program to complete, e.g.
See Checking the Result in a Batch File above for a complete example that also checks the exit code.
start /wait httpwatchpro.exe /S /license=[installed]
Using Chrome extension policies it is possible to force the HttpWatch extension to be automatically enabled in Chrome without any user intervention. This technique is described in the following blog post:
https://blog.httpwatch.com/2021/08/06/how-to-automatically-install-and-enable-a-chrome-extension/