MSI setup installation and uninstallation issues - c#

I have an MSI installer, which have my custom installer project output and I added an exe file to run while installation.
So my MSI setup file will copy or remove files from source location and my custom GUI will install my window server call some server api's and updated its logon credentials etc stuff.
Copying and removing is of files is controlled by MSI on its action as its added as output for MSI project. If I am installing its will copy files or if I uninstall it will remove files.
Now I have below problems -
1) Now if I will go to control panel and try to uninstall my application and later from GUI if I abort it, my GUI will abort but MSI will clear all files.
2) If I will select uninstall and further from GUI, select repair. It will still remove files.
So my installer is not real custom installer, its just namesake one.
Now how can I quick fix above two options?
And is there any better approach to do this task - > my original question create single click msi file of custom installer of an application ?
Thanks in advance

It sounds like you are trying to do things at the wrong time. In any installation system you should gather all user input up front and then once the installation itself starts there should be no further requirement for user input until everything is done.
The easiest way to ensure integrity is to only let the user cancel during the UI gathering phase, not the installing phase. If you do want to let the user cancel during the install phase, you have to pass that on to the underlying engine so that it knows to cancel and rollback any changes made thus far.

It seems to me that you need to set proper conditions for your actions like one that initiates your exe-file execution. Try setting something like "Not installed" so that it would occur only during initial installation but not during remove/repair or upgrade.

Related

Issue faced during uninstall MSI using its Product Code in c#(DTF)

I am creating a CustomBA which will replace the existing install shield Bootstrapper( I don't really know what it's called).
We are installing the same number of MSI as the install shield use to do, so no problem in that.
All the MSI entries in the ARP are removed, as we are making MSI's Visible="no".
Only the Custom BA entry is available in the ARP along with the Install shield Bootstrapper entry, both having the same name.
So after some research I got to know that Windows Installer XML (WiX) ships the Microsoft.Deployment.WindowsInstaller interop library as part of Deployment Tools Foundation (DTF), which can be used to uninstall the MSI.
I am using the below code to uninstall the MSI.
Microsoft.Deployment.WindowsInstaller.Installer.SetInternalUI(InstallUIOptions.Silent);
Microsoft.Deployment.WindowsInstaller.Installer.EnableLog(InstallLogModes.Info, #"C:\Uninstall.log");
Microsoft.Deployment.WindowsInstaller.Installer.ConfigureProduct(productCode, 0, InstallState.Absent, "");
Issue that I am facing are as mentioned below
Firstly I have to run the CustomBA as Administrator to uninstall the existing MSI else it throw as error "Error 1730.You must be an Administrator to remove this application.". Is there a way to run the CustomBA without Administrator and uninstall the MSI.
While uninstall( when I run the customBA as admin), the above mentioned code also remove's the chain packages with it, which I don't want it to do.
After the uninstallation code has been run it does not remove the MSI entry from the ARP.
I've found these links but I don't know if it's relevant:
https://stackoverflow.com/questions/17523974/how-to-uninstall-msi-using-its-product-code-in-c-sharp
Checking for successful uninstall
If you need to be admin then you need to be admin. Allowing a limited user to change areas of the system that are restricted would be a security breach.
You used the word "chain", so it looks like that InstallShield setup was a multiple-MSI install, perhaps with embedded UI that is suppressed. So it appears that the previous MSIs were installed as single-product view and it looks like they are all uninstalled, also as a single product view - they all uninstall. That was probably the intention in the first place - to make multiple MSIs appear as a single product, all installed and all uninstalled. Also, if that IS install was a chain of MSIs then surely you are going to replace them all (or upgrade them) anyway, yes? That's what Burn and BAs will do too.
Which MSI's ARP entry? It's not clear from your post which MSI, assuming you may be referring to one of the chained MSIs installed by IS. And are you sure it is an MSI entry that remains? It might be the chained product's entry that was put there by InstallShield, not an MSI entry. Certainly if your uninstall of the MSI worked its ARP entry would be removed, but may need a refresh to see that it's really gone (but that's a Windows issue). Keep in kind that chained MSI products (and often Burn too) will suppress the individual MSI ARP entries in favor of a single entry that encompasses the multiple MSIs.

c# Check if there is a file on server with specific name

I making a program and wanted to make an update function... So lets say I make one update and put it on my dropbox.. When someone click on update, the program will check if there any file with different name (no same version) on the server and if there is, then start to download it.. Is it possible?
And my second problem I installed my program on my computer but when start the installer again it says:
Another version of this product is already installed. Installation cof this version cannot continue. To configure or remove the existing version of this product use add/remove programs on the control panel.
I want when I run second time installer a confirmation message appear if he want to delete previous version to install this one (I need this for the update)
You could create a web service that provides an index / manifest of a directory that you want to synchronize. The web service could also provide methods for uploading and downloading the synchronized files and folders.
If you are using a Visual Studio Setup Project (.msi) you can simply change the installer version. Visual Studio sees the change and asks you if you want to change the product code. You would say 'yes'. The installer should then remove previous versions before installing the latest. You would also want DetectNewerInstalledVersion = true and RemovePreviousVersions = true.
Not sure if it works for this scenario but you may want to look at a ClickOnce deployment. It may solve both of your problems. ClickOnce Deployment

How does the InstallAllUsers option work?

I have a C# application, and a Visual Studio (2010) Setup Project with it. In my Setup Project, I am using InstallAllUsers = True. Additionally, my application needs to launch at Startup, so a shortcut is being added to the User's Startup Folder.
So I install my application as user Bob (from a share), and then I log off and log on as user Alice. Alice gets a dialogue that says:
The feature you are trying to use is on a network resource that is unavailable.
It provides the network path from which the MSI was installed. So, basically, it's looking for the MSI on a share that Alice doesn't have access to. This is repeatedly reproducible if Alice tries to manually launch the Startup link. However, Alice can directly launch the exe from the installation location, which works fine.
I don't fully understand why it is looking for an MSI, but I guess it makes sense that an application can not be completely installed by one user for another user, so the MSI is needed to complete the installation.
But if that is the case, then I don't understand why the MSI only seems to be required when launching from the Startup link, and not from the exe directly.
My question has several parts:
Is what I am experiencing expected behaviour for the InstallAllUsers option?
If so, how can I ensure that my application is fully installed for all users?
Is it necessary to copy the msi locally, and ensure that it does not get deleted before each user has had a chance to log on?
This is happening because the shortcuts are "advertised shortcuts" hence the greyed out target box.
More info here...
http://www.advancedinstaller.com/user-guide/advertised-shortcuts.html
When an advertised shortcut is launched it validates the checks
associated with the key resources. If any is missing it will fix it by
running the installation package and installing again all information
from the .msi file.
This is why its trying to run the msi.
You can turn off advertised shortcuts by reading this article...
DISABLEADVTSHORTCUTS=1 disables all shortcuts
If its an all users install, then the shortcut will probably want to reside in the all users start menu. Win 7: C:\ProgramData\Microsoft\Windows\Start Menu.
Eric, I would recommend taking a look at the shortcut file contents. You can do this by using Powershell, and there is a SO link to help you on your way:
Editing shortcut (.lnk) properties with Powershell

Force Installation Every Time

How do I force my Wix installer to always install an application? Currently, when I run an .msi file for the second time, the installer proceeds to go to the uninstall screen, but I want to ensure that the installer always installs my application like it did the first time. Are there some best practices for this or anything?
A better question might be...how does the Windows installer know that the product is up for maintenance when you run an .msi file again after its initial install? Because if it just checks the registry, I can remove the registry keys after uninstall...does anyone know? I could really use the help on this one.
EDIT: I figured it out. Installer will install a fresh installation of your .msi if you delete the reference in HKEY_CURRENT_USER/Software/Microsoft/Installer/Products/YOURPRODUCTGUIDHERE. So at the end of your install, throw in a custom action to delete that registry key, for the next install to work :)
I'm not a fan of forcing an installer like that (why not have it remove the existing product first? or try to get the upgrade to work), but you could try using the following from a batch script (or any script type for that matter):
msiexec.exe /fa your_msi_file.msi
This will force an installation of all files. See here for more details.
I figured it out. Installer will install a fresh installation of your .msi if you delete the reference in HKEY_CURRENT_USER/Software/Microsoft/Installer/Products/YOURPRODUCTGUIDHERE. So at the end of your install, throw in a custom action to delete that registry key, for the next install to work :)

Simplifying setup and deployment in c#

I have made an application, which keeps getting updated frequently. So every time a change occurs, i've to include it's fresh builds to the setup and deployment program again and again. Is there any way to simplify the procedure? The files to be added are static in number and exist in a folder. I've heard we can write installer classes in c#, does my requirement has any thing to do with it?
I think ClickOnce doesn't suit my requirement because, for the first time i want it to run like a setup package, since it has some packages and some settings needed to be implemented on the user's machine at the time of install. Can click once help me with that? Also i want to run my application as an administrator and it references to many external dll files. So will it help my purpose?
I finally did it using clickonce deployment. I used content files to mark all the files i wanted to copy to the target computer and used clickonce deployment. Then i modified the way my program starts, so that i can lauch the installer script i wanted to run only when the app runs for the first time. Further i hosted it on IIS and had to change lot of MIME types and add new ones for the download to work over internet
Look into something called "ClickOnce" deployment. It automates a lot of what you're talking about.
EDIT: You can add custom installer actions to a ClickOnce project just like any other, to set up additional components and whatnot. As for permissions, ClickOnce will let you run as administrator if you so choose, but that sort of thing isn't recommended, and it might whine about it.
You can use ClickOnce (http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx) which simplify the deployment process.
Maybe you can also automate the build process using NANT (http://nant.sourceforge.net/).
HTH
Yes, you can do that.
I assume you want the client to update itself when ever there is a new version.
This needs a few changes in the client code. Essentially how it works is check for availablilty of new version at a predefined location. Update you new versions to this location. On the client side, show a message to the user if he/she wants to upgrade to the new version.
You can find a link to sample project out here and here.
You can add a Setup project in your solution inside Visual Studio and then add your other project(s) outputs, or static files to the Setup project as references. The Setup project will then detect your dependencies automatically and each time you do a Rebuild All (or you rebuild/build your Setup project) it will automatically include all the necessary files.
What type of project is it? In many cases, ClickOnce can do the job for you, at nominal effort.
Beyond that - you can usually hook your installer build into your build process; some tools will do this for you.
Installer classes run at the client - so I don't think they relate to your build process...
I would flag the files as Content in their respective properties and then in the deployment project right click the project, go to File System and then right click the folder, click Add and select Content Files from the dialog box. This should copy the newest files over every time you build the deployment project.

Categories