How to avoid install same instance of application wix installer MSI & EXE? - c#

I have an MSI & EXE installer that installs the excel plug-in. The user has option to download exe or msi to install the plug-in. The problem is my applicaiton shows a notification to user if new version of applicaiton is available and if user get new version I always returns the msi file because at that point I don't have any information that user has installed the plug-in through msi or .exe. If user install thorugh exe and install new version with msi the multipe instance installed on same machine. How I can avoid it?
Also, is there any way in C# to know the applicaiton is installed through msi or exe?

You should have two different UpgradeCodes - one for MSIs and one for EXEs. Then new version of MSI will replace MSI, EXE will replace EXE. Also don't forget to upgrade version number, or you will face same issue.
You can't upgrade EXE with MSI, they are treated by system as different products.
How to find the UpgradeCode of installed app

Related

How to create silent installer using ClickOnce

I have created installer(exe) using clickonce which provides GUI for installing my application.
Now I wanted to make this installer to run silently from commandline by taking some of the arguments from command window. Arguments may be like database server name, user id and password etc.
This silent installer should also take care of pre-requisites that I have mentioned for GUI based installer. There is .Net Framework v4.7.1, VC++ 2017 and windows installer v4.5 are my pre-requisites required to be installed onto the target machine if they are not available.
I have tried to read arguments from program.cs Main method, I am now able to fetch argument and able to run installer command line without issue on the machine where my pre-requisites are installed already.
There I have no clue on running .net fx, VC++ and Windows installer from silent installer. Because my installer is not launched because of no prior .Net fx is installed there.
My expectation is to run .Net fx, VC++ and Windows installer before running my installer from commandline window.
Inno Setup (https://jrsoftware.org/isinfo.php) has support for "Running other programs before, during or after install." so you can launch other installers and wait, here is how to install MSI files (you can download and distribute them with your installer):
https://jrsoftware.org/iskb.php?msi
Here are the install parameters that are required for silent installation (you can make a SilentSetup.bat file and execute that):
/SILENT Runs the installer in silent mode (The progress window is displayed)
/VERYSILENT Very silent mode. No windows are displayed.
/SUPPRESSMSGBOXES Suppress message boxes. Only has an effect when combined with '/SILENT' and '/VERYSILENT'.
/NOCANCEL Disables cancelling the installation process.
/NORESTART Prevents installer from restarting the system even if it's necessary.
/DIR="x:\dirname" Overrides the default install directory.
I have used VS Setup projects (no longer supported out of the box), Install Shield (for advanced dialogs during install), ClickOnce (at my employer, which is a pain and can fail by no fault of your code but windows config) and Inno Setup.
Unless you need features that Inno Setup doesn't have, I recommend you go with it, you could also perform custom tasks with either scripting or executing an Exe:
https://jrsoftware.org/iskb.php?custom

WCF Service setup does not uninstall previous version

I have a setup project which gives me a .msi file
Installation attempts fail on this machine, which already had an earlier version installed. A MessageBox reports an error and asks me to remove it from Add/Remove programs.
I have set RemovePreviousVersions = true
Using an updated version it now installs without error, however the referenced dll has not updated to the new version.
What should i do, so that the installer either repairs or uninstalls and reinstalls it automatically?
Please help.

How to deploy a word ribbon

Hi I inherited a word ribbon project. I need to create an installer but first I would like to manually install it(i.e. copy files and run commands in command prompt).
The problem is that I don't know how to deploy the ribbon onto another PC. All I know is that I created a word ribbon in VS and when I run it, word opens and the ribbon appears.
I need to be able to deploy it on word 2007 onwards, 32 and 64 bit where available.
Thank you
I would recommend to create an MSI for deploying your add-in, this is the most used distribution system from Windows, that has built-in support for silent installation, repair, rollback and uninstall. So you can easily have your clients deploy it through Active Directory/GPO or SCCM if they need to.
When using a MSI to deploy the addin you basically copy your add-in resources/files in the desired installation folder and create the registry entries as mentioned by Patrick.
I recommend installing the addin per user, that is to install the files under APPDATA folder and the registry entries under HKCU. Installing per-machine will require admin privileges from your users (maybe not all will have that privileges) and you will also have to work much more to see where to write the registry entries under HKLM, because here you have the key "Wow6432Node" dedicated to 32 bit applications, so based on the edition of WIndows and that of Office you need to see if you will need to write under "HKLM\Software\Office..." or under "HKLM\Sofware\Wow6432Node\Office...". When you install per user under HKCU this problem is gone as under HKCU\Software there is not registry redirection, so the extension will work for all 32 and 64 bit machines/flavors of Office. Also, installing the extension per-user will automatically give your users the possibility to install different versions of the add-in on different accounts from the same machine, if this will ever be needed.
A very important thing, you should have a launch condition in your MSI for Word 2007, so that the users which don't have installed cannot install your add-in also. All tool authoring tools should be able to set this launch condition quite easily.
Also, you should digitally sign your MSI and addin with a code signing certificate (acquired from a certified vendor, like VeriSign, Thawtee, etc...).
To create the MSI package you have multiple options, but basically you can use any tool that is capable to create MSIs, as long as you create the registry entries correctly. For example Advanced Installer (the tool on which I work on) has a nice wizard that just asks what version of Office you target, asks you the files you want to install and it automatically handles the rest for you. You can have it integrate with VS so you build the MSI directly from your VS solution if desired. As for the launch condition, it is just one click away in the Advanced Installer GUI, no need to do any scripting.
You can create a ClickOnce installer by clicking Publish on your Visual Studio project in the Solution Explorer or by editing the registry.

Copy/install application to Program Files automatically when it is first run

When execution an application for the first time, I want this running applicationto be copied to C:\Program Files\
Say I give this application to my friend then he executes it for the first time and this application must do the copy to C:\Program Files\
How to code it?
You are trying to create a Click Once kind of application. Check the link Click Once Deplyment
You cannot move an EXE file while it is being executed, you will either:
have code that copies the EXE to another location
IO.File.Copy()
or have an installer
Click Once installs to a really obsecure location, not program files. It does NOT require admin.
If you add a MSI setup project to your solution you can see this answer to hardcode the install path to C:\Program Files\
If you choose the MSI solution you will need Admin to install. Because the setup.exe is responsible for the downloading/installing components (such as dotnet) it requires Admin to be executed.
If you know the PC your application is going to be installed on already has the .Net Framework & etc then the easiest way to avoid the UAC prompt is to run the MSI not the setup.exe. Running the MSI wont ask for admin.
You can also follow this answer to make your upgrades install to the same folder.

Find MSI install package for pre-installed application?

Here's what I'm looking to do:
I'd like to perform an application install on a remote machine; as a part of that process, before I install the new version, I want to check that machine's registry for a pre-existing version of the same application.
If that machine has an existing instance of the application already installed, I want to find the MSI used to install it, so I can backup the MSI and perform a 'rollback' if necessary. From what I understand, Windows creates a copy of these MSIs and places them in some temp folder with a random name somewhere so that it can use it for uninstalls.
How might I find this location?
(Also, suggestions on how to check the registry values cross-network would be appreciated.)
As far as I understand, you don't have to find the exact MSI package. In order to uninstall a product, it is enough to know its product code and run msiexec /x {PRODUCT-CODE-GUID-HERE}. And product codes can be found under Uninstall registry key (typically, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall).

Categories