MSI installer automatically starting after application already installed when using "Everyone" option? - c#

I have an application that was created using Visual Studio which contains an installation project. When I run the MSI that is built, 3 Windows Services are created. Everything installs fine, the services are there and I can start them, when I choose the option to install for "Just Me".
When I choose the option to install for "Everyone", all users on this machine, the services are still installed fine and I can start them while I am logged in as the same user who installed them BUT when I log in as a different user and try starting the application using a shortcut, the installer starts up and tries to uninstall the services. Weird thing is that it only uninstalls 2 of the 3 services.
Again, if I install using "Just Me" I am having no issues at all, it seems to be linked to the "Everyone" option. I am not sure how to even begin looking into this as I am new to setup projects (this project was created by someone else) so any help would be great.
I'm thinking in one of the installation folders a file must be missing for the second user and that is why the installation folder opens up again?
Thanks for any help.
SOLUTION:
The issue was with the DISABLEADVTSHORTCUTS property of the MSI because the shortcut that was installed for everyone was an Advertised Shortcut as far as I understand. There are a few ways to get around this using a post build event or using ORCA...we ended up using ORCA and adding the DISABLEADVTSHORTCUTS = 1 property to the MSI.
Solution and better explanation:
https://jcrawfor74.wordpress.com/2011/08/17/setup-app-config-during-msi-install-msi-re-installing/
https://support.microsoft.com/en-us/kb/255905

Try to find the called schema.msi under
C:\Program Files (x86)\Microsoft Visual Studio
This prototype is used in the consecutive generation of your deployment msi file. Then, you can use orca to add DISABLEADVTSHORTCUTS=1 to the Property table. So, from then on, all of your msi files will create the standard shortcut.

Related

Detect All Users .msi

I wrote a C# program in Visual Studio that uses the Setup & Deployment Project to create an .msi installer. The "InstallAllUsers" value is set to "True", so it'll install "Everyone" by default, but the users can change it to "Just Me" during setup.
It's just a basic installer - nothing fancy.
My question is this: after they install the program, is there a way to tell which option they chose? Is there a registry key that I can dig for that will tell me whether they chose "Everyone" or "Just Me" during install? I'm not programmatically adding any registry keys, and I can find the "Uninstall" key for my program, but I don't know if there's a value in there that will tell me.
* EDIT *
For a clearer picture:
As I make changes to my program, I increment the version numbers and give the updated .msi to the users, and they just rerun the installer. There was originally only supposed to be a couple of users, so I didn't make a complicated updater. Now there are many users, and the updater is in-the-works. For now, the current users are happy with the process - I give them a new .msi and they run it again - except for one thing: the installer doesn't "remember" their settings from the last time they ran the installer (their words, not mine). I can get the directory of their last install from the "Uninstall" regisrty value and set it with TARGETDIR, so I've got the installation path covered. But I'm trying to figure out if the user changed "Everyone" to "Just Me" the last time around.
One way could be check for current logged in user in registry and see if it has the software listed in in installed software list under HKEY_CURRENT_USER\SOFTWARE\*
There's an example here of enumerating products to find out which context they were installed in. If you know the ProductCode you can just do the MsiGetProductInfo part.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa368279(v=vs.85).aspx
There are APIs for this, so it is more advisable than guessing based on what might be in the registry.
The installation folder properties window in Visual Studio setup projects has an InstallAllUsersVisible property you should set to False. Otherwise it's going to be a nightmare when you do an upgrade with RemoveExistingProducts=True because that requires the upgrade to be in the same context as the original install. You'll find people trying to do an upgrade with All users of an installed Just me product and it will not work.
I don't like per-user installs due to all the problems relating to upgrades, patching, etc... Accordingly I managed to migrate per-user installs to a per-machine during a major update install using Installshield and their built-in ISSetAllUsers custom action plus some re-sequencing of various standard actions. The description can be found here: windows Installer - uninstalling previous version when the versions differ in installation policy (per-user, per-machine)
If you want to migrate all installs to a per-machine install, you could replicate this approach using Phils suggestion to read the current installation context via your own custom action and then run this custom action in place of the ISSetAllUsers custom action that Installshield provides. Then you can follow the rest of the procedure from the link above.

There is no entry in Add/Remove Programs after installing my application (I used Setup project)

I'm very new to Setup project in Visual Studio, I've just tried creating a one, it deployed my files as I configured in the setup project. But after testing the install file (.msi), there was something I can't understand:
There is no entry in the Add/Remove programs list in Control Panel but I tried re-running the setup and it showed a dialog saying that I couldn't setup because there was another version which has already been installed in the target computer, I should uninstall that version first, but I couldn't find an entry in Add/Remove programs and there is also no uninstall.exe file. I tried searching for all entries which contains my application executable file name in Registry and deleted these entries but It still shows me that dialog. (There must be some way through which it can detect another version installed on the target machine).
How I create an uninstall.exe for my deployed application in Setup project??? I thought it should be created automatically for me when I build my Setup project.
Your help would be highly appreciated. Thanks.
There is no uninstall.exe when you are using msi packages to install applications. If you double click the msi of an already installed application you get the choice to do a repair or an uninstall.
What name did you give to your installation package? Maybe you left the default name or gave it some "weird" name different from your application and that's why you can't find it. In 7 you can sort the installed programs by install date and check what's been installed last, don't remember if it's possible in XP.

Process of ClickOnce and prerequisites

I have an application I want to build and deploy via ClickOnce. But we want this to be a process that can be run outside of VS through scripts, for either test, business UAT or production environment.
Each separate environment requires a different .config file to be used and a different web server to be deployed on and for update location.
The application also has prerequisites of .NET runtime 3.5 and Crystal reports.
I have looked into using MAGE to create application and deployment manifests, and if I do a code BUILD, then use MAGE afterwards as per each environment, as well as having the script copy over the correct .config file, this creates what I think are the correct manifests for each environment at the time of running the script.
But what I'm struggling to do is include the prerequisites. If done through VS, you can specify a setup.exe package which gets built with the pre-reqs and deployed alongside the application and when you click on the download link, it installs the pre-reqs from setup.exe and then the application.
But how can I do this manually outside VS? I can build the setup.exe through VS with the right URl location but then how do I link the setup.exe to the application as a pre-req using MAGE to generate the manifests?
The problems we have are 1) The users do not have admin rights to download and install packages, only to install things via clickonce so the pre-reqs have to be installed under the click once security umbrella.
Thanks
ClickOnce and prereqs cause lots of confusion. The setup.exe that Visual Studio generates has nothing to do with ClickOnce. The only minor link between the two is that the setup.exe will launch the ClickOnce application once it finishes. That's it. So thinking users will be able to install your prereqs "under the clickonce security umbrella" is a mistake. If they are not an admin and a prereq install requires admin privileges, they won't be able to install it.
My advice would be to generate your setup.exe one time. You shouldn't need to keep doing it unless your prereqs keep changing. Use Visual Studio, generate the setup one time, then use Mage for the rest.
Edit
In general you make the setup.exe available and depend on the user to know if they need to run it or not. If they already have the prereqs and run the setup.exe, nothing bad happens. It sees that everything is installed then launches the app.
Usually you're going to direct users to run the setup.exe. The next time they want to launch the app they should use the start menu shortcut (assuming you didn't go with "Online Only"). I've found this to be the least confusing set of instructions for users.
Remember how Visual Studio does extra, non-ClickOnce stuff when you publish (like the setup.exe)? It also creates a simple html page that has links to both the ClickOnce manifest and the setup.exe and an explanation. It also has some javascript that checks the UserAgent string to determine if they have the .NET Framework installed. Again, this isn't ClickOnce. It's just something nice Visual Studio does for you. If you like it, use it. I kind of like skipping it and going with the run setup.exe to install then launch from the start menu.
codeConcussion is right, you can't ever actually have the prerequisites instill directly from ClickOnce. You should just generate it once and then you have it ready for your external ClickOnce tool.
There is an option other than Mage. You could use my companies tool, ClickOnceMore, as your ClickOnce build software. It's been designed for people who want to use ClickOnce but don't want to build with Visual Studio.
It can hook into the setup.exe generated from Visual Studio (details here) so should satisfy all your needs.
Why do you want to build setup manually if everything can be done via clickonce ?
You can select "Download pre-requisites from same location" option from prerequisites form if you want to include .netfx or crystalreports, download bootstrap packages for .netfx3.5 & crystalreports and add to folder (for windows 7) "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages" . The deployment project will automatically include netfx & other packages along with setup.exe.
hope this helps.

Creating a patch to upgrade .NET application

I would like to create a patch for my .NET application. The requirements are:
Find the installation directory
Overwrite the old files with the new ones
Restart a windows service
I want to send the updater to the user so that they simply run it and update the application. My original installer is created using Visual Studio Deployment Project.
I did alot if research, and found this:
https://stackoverflow.com/questions/3767/what-is-the-best-choice-for-building-windows-installers
How to Update the installed Window Application (Creating Patches)
http://wyday.com/forum/viewtopic.php?f=1&t=245&p=793&hilit=offline+install#p793
http://www.advancedinstaller.com/user-guide/tutorial-patch.html
I tried created another installer which would just contain the files I need to replace, however I could not find a way to determine the installation directory of my application.
WyBuild seemed like a good solution, however they do not support an offline install and require you to host the update files on the server.
I tried creating a patch using Advanced Installer but it just generates a bunch of build errors that I could not fix.
There are tutorials how to modify the MSI files using Orca or WIX, but that seems alot more complicated than it should be.
I am tempted to roll my own but I am not sure how to go about it, and this seems like such a basic requirement that there's got to be a solution out there already.
If you already use a a VS Setup Project you can deploy the new version of this project and it will upgrade existing installations. Have a look at the setup and upgrade ids. The stop and start of the service can be done by custom actions that can be defined in the project and will be executed i.e. when your setup is committed or rollbacked etc.

Why the shortcut created by my MSI install start the setup process again each time?

I created my MSI installer for our C# application via VS 2008. I installed it. It created a shortcut for me on the desktop. I clicked that shortcut, the setup process running again and at the end our application was launched. It was not like this yesterday before I added some custom action to create database. I didn't recreate the shortcut in the installer. why it is like this?
Open the MSI manually using Orca. Add the following record to the Property table (Property, Value) without the quotes:
Property = 'DISABLEADVTSHORTCUTS'
Value = '1'
This can also be scripted and run as part of a post build event.
MSI comes with an auto-repair feature that checks whether all components installed by MSI are still present when you launch your application using the shortcut.
In your case, probably one (or more) components have been removed so the installer is launched again to repair your installation.
To prevent auto-repair from running either
Make sure no file, registry setting or other installed component is removed
or
Don't set the key path for those components. That will prevent MSI from checking those specific components
From your other questions it seems that your MSI has been created by a Visual Studio Setup and Deployment Project. Unfortunately, there is no option to modify the key path from within Visual Studio. You have the following options:
Modify the MSI manually using Orca (This is not a good option because it is a manual step)
Write a script e.g. using VBScript to patch the MSI file
Move to a more advanced install system which gives you more control such as WiX or NSIS
Is the shortcut pointing to your application or your setup? If it's pointed to your setup and you change it to your application, does the problem go away?
Sounds like the system thinks the installation has been corrupted and is automatically attempting a repair,.Anything in the event logs (look for source of MsiInstaller in the Application Event log).
Have you been building multiple copies?
This happens when the application deletes a file that was deployed during the installation. The Auto-Repair is activated and hence you get the installation screen.
Had the same problem. In my case it turned out the issue was 'Manufacturer' and 'ProductName' fields inside Deoplyment Project properties. It needs to be the same as the folder structure your shortcut is pointing to, otherwise you'll end up with the 'The resource 'C:\Program Files (x86)[Manufacturer][ProductName]\' does not exist' error inside Event Viewer.

Categories

Resources