MSI Installer can be installed PerUser or PerMachine.
I'd like to detect before the new version installation: was previous version installed PerUser or PerMachine?
If PerMachine do nothing because Installer will remove the previous version and install the new one, ok.
If PerUser then check: was it installed user which is the current user?
If current user==user who installed then suggest to user switch installation to PerUser and continue.
Else give message "User 'other_user' need to uninstall manually etc".
The question is: how I can check in c# the user name who installed the current version of product?
Oleg,
Based on other questions you've asked I understand the jam that you are in. It's unfortunate but there isn't much you can do. You could wrap the MSI in a bootstrapper (EXE) to remove any existing Per-User installation for the person logged in ( assuming it wasn't pushed to the machine using the SYSTEM account ) but that wouldn't handle a situation where some other user profile had installed the app.
Here is about the best thing I can think of for your situation. Create your new installer to install to a new directory and new registry keys ( completely different foot print then your old application ). Give this new MSI a fresh UpgradeCode property. Author an active setup registry key to run a cleanup utility the next time a user logs on and then reboot the machine. Put the old UpgradeCode in the Upgrade table just in case you can get lucky for an old per-machine install.
When someone logs in for the first time your EXE will be run. It can then perform MSI API queries to look for old versions of your product and perform an uninstall. In time your old application will be removed.
I recall getting myself into this situations many years ago before I understood the ALLUSERS property. Per-User installations are a pain and only useful for non-privlidged "viral" (as in socially spread) application. It's not a good story for commercial / enterprise applications.
What you want doesn't make sense.
Per-user installations are visible to a single user, you won't be able to retrieve information about the per-user installed apps for user A if you are running as user B. Only per-machine installations are visible for all user.
Take a look here:
http://msdn.microsoft.com/en-us/library/aa369786(v=vs.85).aspx
Note If an application is installed in the per-user installation
context, any major upgrade to the application must also be performed
using the per-user context. If an application is installed in the
per-machine installation context, any major upgrade to the application
must also be performed using the per-machine context. The Windows
Installer will not install major upgrades across installation context.
Now to answer your question... If you are executing an installer per-user and the upgrade installer detects the previous version, that means that the current user installed it.
Related
Sometimes AutoCAD 2009 spoils own menu files and some settings. At this case I recover the application state through the deleting its registry key in HKCU and its folders in the current user profile. Now I am to install necessary components (they recreate the registry key in HKCU and folders). For this purpose I programmatically launch the application. But I want to kill the process when the necessary components will be installed complettely during the application starting (because AutoCAD launching takes many time).
If I kill the acad.exe process, then the components installing will be killed too. I dont need such behaviour.
Is it possible to define (programmatically, I use C#) the moment when the installing of these components was finished? Or maybe it is possible to define that some components of the application are not installed on the current user profile still and then to force the launching of these components installing without the application launching (I don't know how to do it).
If you delete files or registry entries from the installed product, it's a feature of Windows Installer that it repairs the install at certain trigger points, one of which is using an advertised shortcut. If you don't want that application to actually run and want only the repair, then an alternative is to go to Programs and Features, select the product and Repair it. Or right click the MSI file and choose repair.
I have a C# Windows Forms project that I created.
When i click "Publish" it deploys this click-once application that is only for a single user. If I run the install on my admin account, then there is a shortcut in my AppData that i can click on to run my program. If I try copying that shortcut to C:\users\Public what happens is that another click-once application gets placed on the users' desktop. That user then has to run the install and is annoying cause If i have an update, each user has to uninstall and reinstall the new application. Is there any way to configure VS 2015 to publish in a way that creates an "regular" install for all users?
RobinDotNet addressed that in a blog post a while back:
Doing an all-users install is counter to the design goals of ClickOnce deployment, so I think it’s going to be something everyone has to live with, at least for now. Using XCopy or a setup & deployment package and rolling your own incremental update methodology would be the way to go if you absolutely have to have an All Users installation
https://robindotnet.wordpress.com/2009/09/07/installing-a-clickonce-application-for-all-users/
There are more alternative deployment methods listed in this SO answer that might work for you.
You can not do this using ClickOnce. You may want to install Windows Installer XML to create regular MSI installers. It nowadays integrates with Visual Studio.
As others have pointed out CO is per user. There is no install for all users on the machine option.
However I feel you are either misinformed or badly misconfigured something regarding the implications when it comes to upgrades. Click Once upgrades don't require the user to uninstall, download, and install a new version. That wouldn't exactly be click ONCE.
You can configure your ClickOnce app to automatically detect, fetch, and apply upgrades as you make them available. This can be done either in code so you can control it programmatically or by configuration (i.e. check for updates every time the application starts).
So yes each user would need to install the application once but that would be the end of their involvement.
I have inherited a C# software application which has an auto-update component. This component works pretty well, it stops the application, updates any files which have changed, then restarts the application. The software is initially installed using an MSI file.
However what this auto-updater doesn't do is update the windows installer database with the new application version number, nor does it register any new files which didn't exist in the original installation.
Looking at the installer API (https://msdn.microsoft.com/en-us/library/aa369426(v=vs.85).aspx) there doesn't appear to be any way to modify the configuration in this way.
And from what I have read (http://blogs.msdn.com/b/windows_installer_team/archive/2006/05/12/595950.aspx) modifying the registry entries directly isn't recommended.
Somehow many applications manage to accomplish this e.g. Google Chrome.
Is there a way to accomplish this without directly modifying the registry?
If not, can someone tell me (or point me to) the exact registry entries that would need to be changed. Including how to find the guid of the product entry in the installer registry section.
Windows Installer updates can be installed with upgrade .msi packages or patches. There's no other supported way of updating MSI's internal registration.
Google doesn't use MSI to install Chrome, so they had to invent their own patching system.
Can I ask the user WHERE to install the application during install time?
Most setups prompt the user where to install the application, I'm sure you are familiar with it. How can I do this with the visual studio publisher? (If it cannot be done from the VS publisher could you reccommend a program that can do it? Or do I have to do it manually?
As per this MSDN post: "ClickOnce application are installed per user in the user application cache. These applications are managed by the ClickOnce service. If you want to install to a user specifed location such a Program Files... you should use MSI or some other installer technology."
The other deployment methodologies supported by Visual Studio are discussed here
No, you can't. ClickOnce install the application in a user's AppData folder it's not installed like a traditional application. If you want to have more control over stuff like this you need to write your own installer.
Not sure if it is changed, but ClickOnce applications are installed per user in the user application cache. You cant change that location. This means that if 2 different user share the same machine there are 2 different copies of your application.
I have found strange issue during execution of installatio file made by VS 2010. The installer should copy some files into App Data of current user. When I run installer on account with admin privileges, everything is ok. Problem appears while installing on guest account. For example I try to install app on guset account A. I must select run as option. I choose user B with admin privileges. After installation all files are copied into folder App Data of user B, not A as I expected... why? Is there any solution for this?
It is called deployment project and it is outdated and broken technology - I suggest using WIX. Those stupid proejcts should hnever have been in Visual Studio - they dont even adhere to the basics how MSI files should work.
One thing you can not nicely control is the elevation request needed for activating admin priviledges. WIX allows you full control over the MSI features.
I must select run as option. I choose user B with admin privileges. After installation all files
are copied into folder App Data of user B, not A as I expected... why?
Ah - logic? You install AS USER B - so surely the files go into User b's folder.
in general you need admin priviledges to install softawre. A gues can not do it. Point. Installation is a tricky high priviledge thing, not something for someone who has no rights on the computer.
The installer should copy some files into App Data of current user.
Invalid per definition. Point. A normal install run should not install anything into a user's app data - what is another user runs the software? The software can make copies when it starts (from shared app data), but a NORMAL install (not a per user install) should never put stuff into the users personal AppData folder. This is a violation of basic MSI principles.
Symantec has a good documentation on the only valid way to do that (and sorry, setup proejcts just dont support advanced features for MSI:
http://www.symantec.com/business/support/index?page=content&id=HOWTO4840
As it reads:
In order to install files to each user's profile, a self-repair of the application must occur.
WIX has similar answers in a post:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing-files-to-user-s-application-data-folder-td5377311.html
I assume you don'd o a per user install ;)
I also assume you don't set the registry key according to ICE38 (setup warning):
http://msdn.microsoft.com/en-us/library/aa368961%28VS.85%29.aspx
In general: DO NOT DO IT. User AppData can / should happen when the user starts the app.