Check if service is running in WiX - service

Recently I had a problem in a costumer's computer. Our installer would hang during install and uninstall. Eventually I found out that the winmgmt service wasn't running, and that was causing the problem. For some reason it was disabled.
I would like to add a check to our installer, to guarantee that the service is running when installation begins. Preferably, with a helful error message if it isn't running.
I know I can do this check with a custom action, calling QueryServiceStatusEx from a C program. It can probably be done in some way in VBS too. But i would like to avoid custom actions, if possible. We had some problems with antiviruses, and dependency with WSH.
So, in short:
How can I check if a service is running, in WiX?
(I don't have much experience with WiX. The guy who wrote the installer left the company and now I do the maintenance)
Thanks!

There is nothing built into the Windows Installer to check the status of a service. You will need a CustomAction. As you've found script CustomActions should not be used, see: http://blogs.msdn.com/robmen/archive/2004/05/20/136530.aspx

Related

Calling SCCM from PowerShell or CMD

We have an application (really a platform) which we need to customise on a per-user role basis. This involves asking some questions and then installing the application and then customising it before handing back to the user.
After the app has been installed, we need to update the application (but not the settings) from time to time as new versions are released.
Our IT people have said I should use a PowerShell/cmd script to do the initial install - because of its specificity. I'd like to get SCCM to do the version updates but I've been told that if SCCM doesn't do the install, it doesn't know there's anything to update - fair enough! So I was wondering how can I call SCCM from my PowerShell script to perform the initial install and then return control to my script for final customisation?
On this site you can learn more about managing SCCM over PowerShell:
https://learn.microsoft.com/en-us/powershell/sccm/overview?view=sccm-ps
But this won't be just a simple script, it will take a bit of time to create!

Trick MSI API into thinking that an upgradecode is installed

I'm testing the compatibility of two products (A) and (B) within a TestAutomation project. The test verifies that product (B), which is actually the product under test, can be installed eventhough (A) is already installed --> to do so, the installer of (B) looks up if the UpgradeCode of (A) is present.
NOTE: I already know the UpgradeCode of (A). What I'm trying to do is to write it into the table that will be looked-up upon installing (B), WITHOUT actually installing the MSI of (A) - this is kind of like a "mock" in integration-testing.
The test is running on a VM where (A) is not already installed by default. My goal would be to write a script which would allow me to skip the "real" installation of (A).
QUESTIONS:
I'm not sure of where it looks the UpgradeCode up. It is NOT looking it up in the registries (I aready tried that hack). I have found the UpgradeCode within the Win32_Property table... is that the right place to look into?
My guess is that I have to emulate the API-call, with which the original MSI from (A) sets its UpgradeCode... any idea of how that works? Possibly with a Powershell script. I have seen online people modifying the WMI properties tables can with calls to gwmi (then using put) or swmi, but all my attempts so far failed.
NOTES:
I do not really know my way around with the Windows Installer nor with PowerShell... this is not at all what I usually do. An answer in Layman terms would be much appreciated.
I know that there are other ways around this (e.g. a dedicated VM or performing a "real" installation of (A)), but I'd like to know how to achieve this programmatically.
Why I need to do that? It's an automated test that only concerns the installer of (B). I do not want the success of my test to be depending from (A)'s successfull download or installation.
The easiest way to do a test without installing the actual A would be to produce a small MSI with the same UpgradeCode and ProductCode and install it. I can't see why you want to "fake" it when you can just do the real thing.
If you want to prevent the install of B when A is already installed you could add A's UpgradeCode to B with OnlyDetect=yes, that will set a property that can be used to prevent B from being installed. It's not clear what the context is for not installing B, whether you have external launchers, a bootstrapper, or which tool is being used to generate the MSI (because some tools will give you help if you want to skip B if A is installed with their built-in detection features).
You can get the UpgradeCode via WMI (Win32_Property WMI table) or via MSI API (Windows Installer Database - registry).
I would not hack the upgrade code in the Windows Installer Database for any reason. Why do you need to fake the UpgradeCode? Is the install of product A very large?
WMI / PowerShell / VBScript:
How can I find the Upgrade Code for an installed MSI file?
WMI is very slow to use, and can cause side effects such as self-repairs and in certain cases spam the event log with error messages. See the Disclaimer section here.
MSI API:
You can use MSI API COM calls (VBScript, Javascript, etc...) or MSI API Win32 calls (C++).
Here is a hacky way of getting the Upgradecode via
a session object using VBScript. I am not sure what side-effects - if any - result from spinning up many session objects: Is MsiOpenProduct the correct way to read properties from an installed product?

Install4j exception during all installations

When trying to install any Install4j installer (tried with several different of our installers that are normally working correctly), I get the following Setup error on my Windows 10 laptop:
The installation/removal of a previoius program was not completed. You will need to restart your computer to complete that installation.
After restarting your computer, run Setup again to complete the installation of Program name.
Restarting my computer does not help. Removing the "PendingFileRenameOperations" from the registry did not help either, even after restarting (from https://support.microsoft.com/nl-nl/help/310335/error-message-the-installation-removal-of-a-previous-program-was-not-completed ). The install4j logs do not mention this problem, so no help from that either.
This issue started after doing some program uninstallations (both install4j and not install4j) and some got stuck and needed to be stopped with Task Manager.
Please check the registry keys
HKEY_CURRENT_USER\SOFTWARE\ej-technologies\install4j\RebootCheckFile
HKEY_LOCAL_MACHINE\SOFTWARE\ej-technologies\install4j\RebootCheckFile
and remove them if they exist.

Can i use a wix installer to just run a couple of custom commands

I am working on a project where we need to repeat certain steps with powershell to deploy stuff. i would like to create a process/install guidance (steps supported with UI) with WIX but after the msi has finished i have an entry in programs and features. I just need it to execute the powershell and the end without registering in windows. i might be using the wrong tooling or whatever, any suggestions are welcome.
Definitely not recommended unless you want to track the deployment of these scripts on different systems by checking the entries in ARP (Add/Remove Programs), and even then it clogs up the Add/Remove view of your computers. Most system administrators hate this approach, it is better to just write to your own registry key and read it back from every machine.
What are the scripts doing? Are you actually installing files.

Need Help Writing a multiple program installer that gets installer from a webserver

Okay, I am trying to write an installer that installs multiple programs. The installer needs to be able to either get the files from a web server, or be able to package the files into a single installer file.
The end result I am looking for is a user hits a webpage, they can click a link to download a single installer file and the installer goes ahead and installs each of the programs. Quiet installations would be preferable but not absolutely necessary. I am trying to make this as user friendly and idiot proof as possible.
Grabbing the installers for each program from a web server would be preferable so it always grabs the latest version and I will not have to tweak the installer script each time the programs are updated.
I have looked into NSIS and MSI, and neither seem to be able to do what I need. I have entertained the idea of using Java Web Start to run a Java program that can install everything, but I am not sure the plausibility of that. If that is possible, then the user would not even need to run a file the Java Web Start would just take care of everything.
Perhaps Ninite will help.
If not, there are two possible solutions:
You can try using a MSI wrapper which installs the applications as prerequisites or through custom actions. It's dirty and complicated, but MSI is a standard.
You can write your own application which handles the installers. This is most likely the best approach.