Windows - intercepting binaries before installing - windows

How can I intercept moment before installation of any binary on Windows? I would like to stop the process before installation and execute some Python/PowerShell scripts. After that stop the installation process or permit of installing certain binary, it depends on the script's results. Does exist some windows API responsible for that type of operation?

Related

Looking for installer with ability to create custom UI and custom installation type

Have been looking for an answer for a week now but still can't find one.
Few words about the problem:
I'm working on Windows Remote control desktop application similar to TeamViewer and we currently using both WiX and NSIS to create our installers. The problem is that we have an Remote control Agent that can be installed in 4 different ways:
Install as unattended service
Install in On-Demand mode
Install in ReachMode mode ( update/uninstall the agent when the machine is outside of the LAN)
Install as a service via on-demand mode.
Depending on installation options. (eg. "setup.exe /ReachMode") - we have different UI and very different installation configuration.
Also when creating installer we add a payload to the end of .exe file and than when installing we look for a payload, read the value and make our decision on type of installation
Currently Agents installation implemented in NSIS and main program installation implemented in WiX.
My task is to Replace NSIS with a different installer (like WiX or similar)
My Question is:
What installer can accomplish these types of customization? Any help/recommendation would be helpful at this point. (Also agent would be installed on WinXP, Vista,Win7, 8 and 10)

Installing .pkg: determining if the app being updated is presently running?

I'm using the brilliant Mac OS X "Packages" to generate an install a .pkg, and wondered how one constructs a shell script to make sure the application file being updated over isn't presently running (which would seem like a Very Bad Idea).
Normally this would be handled by using a pre-install script, or installer plug-in. It's unclear what you plan on doing though if the application is running.

I want to install complete software using command line for test automation

Let take as one example, I want to install Java on my machine using the command line so I just type below command as administrator:
start /w jre-7u51-windows-x64.exe
I also tried below command in order to get help from command line
jre-7u51-windows-x64.exe /?
Now a pop up appears in which we need to click the "install" button.
I don't want any user interaction and I want complete installation using command line.
Is there any way to automate the install button click?
If any other technologies available for this also let me know.
You need to use the /s silent installation switch.
Source How do I arrange a silent (unattended) Java installation?
Command-Line Installation
The Java SE 7 Windows Offline Installer command has the following syntax:
<jre>.exe [/s] [INSTALLDIR=<drive>:\<JRE_install_path>] [STATIC=1]
[WEB_JAVA=0/1] [WEB_JAVA_SECURITY_LEVEL=VH/H/M] [SPONSORS=0]
Note:
.exe is the single executable installer for the JRE.
/s, if used, indicates a silent installation.
INSTALLDIR, if used, specifies the drive and path of the JRE. If INSTALLDIR is not specified, the installation will go into C:\Program
Files\java\jre (default location).
STATIC=1, if used, specifies a static installation. For more information about static installations, see Static Installation in
Patch-in-Place and Static JRE Installation.
WEB_JAVA=0, if used, disables any Java application from running in the browser.
WEB_JAVA=1, the default, enables Java applications in
the browser. This field is available as of the 7u10 release. For more
information, see Setting the Security Level of the Java Client.
WEB_JAVA_SECURITY_LEVEL, if used, sets the security level of unsigned Java apps running in a browser. The possible values for this
field are VH (very high), H (high, the default), or M (medium). This
field is available as of the 7u10 release. For more information, see
Setting the Security Level of the Java Client.
SPONSORS=0, if used, entirely bypasses sponsor offers such as browser add-ons. This field is available as of the 7u55 release. Note
that sponsor offers, and therefore this functionality, is only
applicable to online 32 bit JRE installers and Auto Update mechanisms.
Source JRE Installer Options
Installation Configurations
Example 1
Suppose the JRE installer is
jre-7-windows-i586.exe and you want to install the following
configuration:
Perform a Windows Installation
Install the JRE core, additional fonts, colors, and Soundbank
The command to install the above mentioned configuration is as
follows: jre-7-windows-i586.exe /s
Example 2
Suppose the JRE installer is jre-7-windows-i586.exe and you
want to install the following configuration:
Perform a Windows Offline Installation and install the JRE on D drive at java\jre
Have all features of the JRE installed
The command to install the above mentioned configuration is as
follows: jre-7-windows-i586.exe /s INSTALLDIR=D:\java\jre
Note: To keep the MS-DOS window open, until the installation of Java
is complete use the start /w command as follows: start /w
jre-7-windows-i586.exe /s
"I want the command in terms of general use for other applications not only java"
Note that there is no general solution to this problem, since there are many different types of installer and installers for different programs will likely have different "popups" (and may even change when new version of the program are released).
Read the whole of following link for a full discussion of how difficult this is.
Unattended/Silent Installation Switches for Windows Apps
The goal of this document is to collect instructions for performing unattended / silent installations of many popular application installers. Such instructions are useful for automating these installations.
The document includes instructions for silent installation using many different installer types.
It also includes a suggestion for a tool AutoIt:
AutoIt can simulate key presses and mouse clicks, following a script customarily named with a .aut or a .au3 extension.
Most installers have a sufficiently simple and consistent interface that a very short AutoIt script suffices to automate their installation.
...
AutoIt scripts do have drawbacks.
First, you must be careful when upgrading to new releases of an application, since the installer's UI may have changed.
More worryingly, AutoIt scripts are theoretically unreliable because they do not let you determine when a sub-process has exited. You can tell when AutoIt itself exits, but that is not the same thing at all. For example, an installer's last window might disappear while the installer was still working. Your master script, waiting only for the AutoIt executable, would then proceed, starting another installation or rebooting the machine.
There are other such tools available.

DllRegisterServer failed for comct332.ocx

I have a VB6 application I am trying to get working on a Windows 7 environment, however every time I start the application, I get the error:
"Component 'ComCt332.ocx' or one of its dependencies not correctly registered: a file is missing or invalid".
To resolve, I have tried to register the comct332.ocx file by running the regsvr32 in the Command Prompt in Administrator Mode but then I get the error:
"The module "comct332.ocx" was loaded but the call to DllRegisterServer failed with error code 0x80004005"
Other things I have tried include:
Deleting all parent nodes in the registry where 'comct332.ocx' exists
and running regsvr32 again in Admin Mode. Same result.
I granted admin permission to another user on the PC and I could register the
file successfully, and the application starts and runs successfully!
However when I log in as the previous user again, it fails miserably.
Any help, thoughts, other-things-to-try will be much appreicated. Thanks
If you have been keeping up on things as you must if you are to continue using VB6 successfully there are a number of things you'll be aware of.
One of these is the impact of UAC and per-user registry
virtualization.
Another is the impact of SysWOW registry redirection on 64-bit
systems.
You will understand that proper installation packages are more important than ever before. Windows has many auto-remediations for legacy software but some of them will not result in applications having all of the originally intended behaviors. Most of them will only be applied when your application "follows the right path" from installation to second run.
Here we have a case that is intended to be handled through use of a proper Windows Installer package, or at least a legacy setup recognized as such through Windows' "legacy installer detection heuristics." In general legacy scripted setups are deprecated but as long as they stay on the path Windows makes efforts to ensure they succeed.
Manually deploying by just copying over a bunch of files and randomly running regsvr32 on some of them has a reduced chance of success. This was never an approved method of deployment anyway.
You have most likely run afoul of some combination of registry virtualization and redirection.
The regsvr32 utility is a development tool, not a deployment tool. If you insist on trying to use it for deployment you must follow the same rules a developer must follow:
Run the correct version. On a 64-bit system there are both 64- and
32-bit versions of this utility. The 32-bit version which you must
use is located in the SysWOW64 folder.
Run it from an elevated command prompt. An easy
way to start one is to type <Winkey>cmd.exe<Ctrl-Shift-Enter> then
approve the UAC prompt or provide over-the-shoulder admin credentials
as needed.
There are many other things you need to know and handle in order to be successful. If you have ignored those most of them will only become apparent to you after your program gets installed and will run. A lot of them stem from filesystem virtualization.

Observing how an MSI installer is installing an application

I am trying to find out how a driver is being installed on the system from a MSI setup package. I am currently using a program called InstEd to try and get an idea of what its doing:
http://i.imgur.com/b9USo.jpg
I am interested in "MsiProcessDrivers" and "MsiInstallDrivers".
Can anyone reccomend how I can see how the drivers are being installed?
The MS Sysinternals suite has some tools for monitoring registry and disk operations. Just run them prior to running the installation, and note the actions that are performed by the installer.
Sysinternal's Process Monitor will show file system and registry changes being made: filter by msiexec processes.
Warning: for a non-trivial install this is likely to be a lot of operation.
The two custom actions you reference (MsiProcessDrivers, and MsiInstallDrivers) are part of the DIFx Driver Installation Framework as used with Windows Installer.

Resources