Why programs need installers

It turned out that the developers in every possible way hide them in the installers of their programs, trying to benefit from this. Maybe it would be easier to do without software installers at all?

This entry lay in drafts for almost a year, until there was a reason to return to the topic of installers, which gave ... Windows 8. And although today's story is not directly related to one feature of the new Microsoft OS, the next article will be entirely devoted to it.

Let's look at the main scenarios for using installers to understand why they are needed.

Today on the program

Checking the rights to install the program

I will dwell on this topic in more detail, since it touches on one aspect of the connection between UAC and program compatibility that I did not touch on earlier.

In modern Microsoft operating systems, verification of rights to install the program is implemented by a user account control request. You can embed a manifest in the installer that prompts a UAC prompt when the executable is launched or during the installation process, if desired.

You can specify three types of installer behavior using the manifest:

  • asInvoker launches the program with the rights that the user currently has. If you are running with administrator rights and UAC enabled, it will start with normal rights. When user account control is disabled, the program runs with full rights.
  • highestAvailable shows a UAC prompt to an administrator, but not to a normal user.
  • requireAdministrator Forces a User Account Control prompt that requires administrator rights.

For example, the Opera browser is first unpacked into a temporary folder, from where the installer is launched. Moreover, the UAC prompt is not displayed, because administrator rights will only be needed if you install the browser for all users.

If you choose to install to a profile or to a USB stick, the UAC shield will immediately disappear from the button.

This is a good example of a smart installer, although not every IT professional will share this opinion. After all, this approach unties the hands of users, allowing you to install programs in a profile. Therefore, administrators must use SRP or AppLocker to effectively disable.

Program Compatibility Levels

The above manifest settings are related to the compatibility level of the program. In the properties of any executable file, you can specify the operating system with which the program is compatible.

These settings are reflected in the user registry key (HKCU), but you can apply them to all users in the HKLM key.

Windows Registry Editor Version 5.00 "C:\\Program Files (x86)\\PortableSoft\\BK ReplaceEm\\replacem.exe"="WINXPSP3"

The parameter name is full the path to the program, and the value indicates a compatible OS. In the properties of the executable file, it is not possible to specify the level of rights to launch, but it can be specified in the registry as a parameter value:

  • RunAsInvoker- current rights
  • RunAsHighest- the maximum rights available to the user
  • RunAsAdmin- Mandatory admin rights

By the way, XP compatibility mode requires full rights.

Experiment with the rights to run the program

The registry editor (regedit.exe) is set to run with the highest available rights (RunAsHighest). In practice, this means that:

  • The administrator must agree to the User Account Control prompt. As a result, the Registry Editor opens with full rights, giving you the ability to make changes to any registry keys where you have write permissions.
  • An ordinary user immediately opens the registry editor, but with limited rights, i.e. can only make changes to HKCU.

I suggest doing an experiment on the command line - this will avoid fiddling with the registry, and also reveal another way to run a program with certain rights.

The experiment only makes sense if you have User Account Control enabled.

Log in as an administrator, open a command prompt with normal privileges, and launch the Registry Editor:

start regedit

As usual, you will see a User Account Control prompt. Now run:

Set __COMPAT_LAYER=RunAsInvoker start regedit /m

The first command sets a variable that defines the compatibility level for all programs running in this console session, and the second one launches another instance of the registry editor (key /m). As a result, it will open with normal rights.

In Process Explorer, you can clearly see that the first instance (PID 3880) has a high integrity level, and the second (PID 7480) has a medium level corresponding to normal rights. With these rights, you will not be able to make changes to HKCR and HKLM, which I suggest you check for yourself.

Thus, you can always run regedit with normal rights, even as an administrator, if you use the above batch file or specify the RunAsInvoker startup type in the registry.

Windows Registry Editor Version 5.00 "C:\\Windows\regedit.exe"="RunAsInvoker"

However, let's get back to the installers.

Reducing the size of the installation package

You saw above that the Opera installer is first extracted to a temporary folder from a self-extracting 7-zip archive. The combination of a good level of compression and an open license allows developers to reduce the package size and save on traffic. Not surprisingly, Mozilla uses exactly the same strategy when packaging their software products in 7-zip.

Other companies may use alternative file compression tools. Microsoft generally uses the CAB format.

Copying files to a specified folder and creating shortcuts

During installation, you can specify in which folder the program will be installed. This procedure is primitive, and most users can easily handle it even without an installer. The same can be said about creating shortcuts.

Thus, these functions serve for our convenience and time saving.

Integration of third-party programs

As we found out a year ago, this trend has gained immense popularity. Returning to the AIMP and Yandex.Bar example, we can consider two integration options.

Previously, Yandex supplied its panel for browsers in the form of an MSI package, which the developer built into the installer of his program. The package had special Windows Installer properties that allowed for flexible installation customization.

Msiexec /i YandexPackSetup.msi YAHOMEPAGE="y" YAQSEARCH="y" VENDORSPECIFIC="some text" /qb

Now installation has become more intelligent due to the fact that the panel is loaded from Yandex servers only if the corresponding checkbox is checked during installation.

Obviously, due to this approach, the size of the distribution package of the program is reduced.

Ability to uninstall and restore an installed program

Having touched on the topic of MSI, I want to dwell in more detail on the most popular type of installer for medium and large programs.

Uninstalling programs

Let's see how the process of uninstalling the program supplied in the MSI package takes place. By the way, it can hide in any nice installer shell, like InstallShield .

The package is cached in the Windows Installer database, the %SystemRoot%\Installer folder, where you can shed light on obscure filenames by adding a "Subject" column.

When you uninstall a program from the control panel, the system finds the uninstall command in the registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

Here, each program has its own subsection. Parameter UninstallString contains a Windows Installer command that points to a package identifier (GUID). The package is searched in the %SystemRoot%\Installer folder by the Revision property.

When using other installers, this parameter may contain, for example, the path to the uninstall.exe file containing instructions for uninstallation.

Restoring programs

Restoring MSI packages is similar to installing, but the difference is that this requires original the installer package specified in the parameter InstallSource. The picture above doesn't show very well, but my path points to a temporary folder in the IE9 cache (I ran the install without saving the file). Since the folder was already cleared, the restore won't work.

To ensure full recovery (as well as changing a set of components), programs can cache their original installation files. Sometimes the ProgramData folder is used for this, and Microsoft Office creates a hidden MSOCACHE folder at the root of the drive.

Is it possible to delete files from the Windows\Installer folder

If you have been working on the current system for a relatively long time and installing various programs, the size of the hidden system folder %SystemRoot%\Installer can be measured in gigabytes. No wonder people with a small system partition are wondering if it's okay to delete files from it.

The short and simple answer is no, you cannot delete files from this folder.

In practice, removing a package will result in the system having incorrect information about the installed program. Consequently:

  • Recovery stops working. You saw above that the Windows Installer relies on the cached MSI package for this operation and will not restore anything without it.
  • There may be problems uninstalling the program. If it starts to work incorrectly, you will definitely have to re-download the distribution package of the program and reinstall it. However, registry entries may prevent this because Windows considers the program to be installed.

But sometimes the understanding of this comes already after the fact, although even in this case all is not lost.

Troubleshoot problems installing and removing programs that use the Windows Installer

In principle, you can try to delete entries in the registry manually, but it is better to use a special diagnostic package Fix it. It is designed to fix problems with installing and removing programs that use the Windows Installer (the picture is a direct link to the package).

If the problem persists, you can search the software directories for the Windows Installer CleanUp utility.

Microsoft once released it to troubleshoot Office installations, but the utility is no longer compatible with its newer versions. Therefore, the company no longer distributes and does not support the utility, instead releasing a universal Fix it (there is a separate version for Office 2013+).

Registering Components and Creating Registry Entries

Any serious software package (for example, Microsoft Office) will definitely require full rights to register its components and libraries, as well as create entries in the HKLM registry key. Such tasks, necessary for the normal operation of the program, are always assigned to the installer.

However, this need is not vital for all programs. So, you can not install the Opera or Firefox browser, but copy the files unpacked after running the installer to any folder. After launching the browser, a separate folder will be created in the % appdata% folder of your profile to store settings and cache. At the same time, entries related to the browser will appear in the HKCU registry key.

Thus, you get a "semi-portable" program. It works without installation, but leaves a lot of traces in the system that can only be covered manually.

One way or another, you can put a shortcut on the desktop or taskbar, associate the browser with its file types, and work normally.

Association with file types and registration in default programs

The association of file types and protocols with any program (for example, changing the default browser) is a user setting, i.e. it does not require administrator rights.

There are several ways to associate a program with its file types and protocols, one of which is shown in the figure above. I will analyze them in great detail in the next post, because Windows 8 has changed in this aspect!

Poll and discussion

As you can see, a lot of tasks are assigned to program installers - from primitive unpacking of files and creating shortcuts to managing the state of the program and its association with file types and protocols.

I am sure that many readers of my blog actively use portable programs, which in itself is not a problem.

However, neglecting the installer of the program in the case when it is necessary for its correct operation and configuration, as well as for recovery and removal, can lead to an extraordinary situation.

In the discussion, I would like to bring you to the next entry, which will be one of the largest in this blog. In particular, I'm interested do you use in your basic system portable programs that you associate with more than one file type(for example, a browser, text editor, or media player).

In the comments, please list these programs and explain why you are using portable versions instead of full installers.

You can mark fragments of text that are interesting to you, which will be available via a unique link in the browser's address bar.