download click once application from browser - c#

i was working on win application made its setup, and put it on site. when some user comes to site for first time it pormpts user to download my application. and while running setup i created a key in registry, that was checked in my script by site, that if key exists than user will not be prompted as he/she has installed app. when user uninstalls application, setup will delete regisrty key, wirtten on installation time.
Note: i added my site to trusted site and chaged its security to read my script.
Now scenario changes, user has asked to implement app in clickonce, so that they had to update app instead of uninstall and reinstall it. they still want clickonce app setup on site as mentioned above, but problem here is that when i run app first time it will write registry for that application but on uninstall it will not delete registry. as it is mentioned in following link set registry key through click once.
is there any way to accomplish this requiremnent. any help will b appreciated

check the update option is enable in the Publish settings ( if needed specify the minimum version for updating specify it also) .
when the application starts it will automatically checks for update. user dont need to uninstall every time

If you want to remove a registry key before the application uninstalls you will need to launch the uninstall process from a location within your code that you can control. To do this, you will need to have the user launch the uninstall process from within your application. When the user starts the uninstallation process, you will need to remove the registry key from within your application before continuing the uninstallation.
There is an excellent blog post (found here) by Jim Harte regarding automating the uninstall/reinstall process. His article is in regards to an issue with certificate renewal, but the uninstall process is the same.
If your user uninstalls the application through the Add/Remove Programs dialog, the key will not be removed. There is unfortunately no way that I am aware of to halt the uninstall process of a ClickOnce application so that you can remove a registry key. It's just an annoyance that you will have to live with, unless someone else around here has found a "creative" solution.

Related

Why does my c# application not start automatically on logon?

I have created a c# WPF application. I would like to run it automatically when Windows starts and/or when the user logs on by using the Windows registry. I don't have problems with my code, because when I set the path in the registry manually it won't work too.
Also the next topics won't help me further:
How do I set a program to launch at startup
How to run a C# application at Windows startup?
Autorun the Application using C#
However, I found out that when my application is located in the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\ key it will startup automatically when I log on. But actually I read elsewhere (on the MSDN website) I just could put it into the HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run key but this doesn't work for me. However, other applications in those last key paths will startup..
I don't prefer the WOW6432Node one, becuase it's based on 64-bit systems and maybe the customers doesn't have a 64-bit system, so I prefer using the other key paths but I can't get it work.
Does someone know how to fix this? And why my application is starting in the WOW6432Node one and not the other key paths?
I also checked my Event Viewer log but I never found any errors, the application won't run. Also the application is enabled in the Task Manager startup tab, so that's not the problem.

How to remove registry keys on uninstall msi using WIX

I need to remove registry keys when user uninstall application.
These registry keys are in HKEY_CURRENT_USER\SOFTWARE.
I am using WIX tool.
Please note that keys are not getting registered on install but after login based on action performed by user.
Thanks in advance
Windows Installer can only access the registry hive of the user it's running as. It's technically possible to write a custom action to enumerate the user profile list and load each ntuser.dat but this ultimately causes all sorts of problem. The short answer is it isn't practical. Besides, Microsoft standards state to leave user data behind on uninstall.
If you really want to do it, the best way I know is to use a custom action to write to the registry during uninstall (something MSI doesn't support). Have this registry value set up an ActiveSetup command to invoke reg.exe delete. Then when each user logs in next time the key will be deleted.

How to automatically update my windows application WITHOUT prompting the user to do so?

I have seen there are many technologies out there that make auto updating easy for the user (such as winsparkle). The problem we have is we want to be able to auto update our desktop (c#/c++) app without prompting.
If users have the ability to NOT update it makes our lives hell (10,000+ installs all need to be updated about once a month).
We currently install our application via WIX and it reinstalling a new version completely overwrites what was there before. This works fine but we'd love to not even have to run the new installer, thus the idea of auto updating.
I've looked at clickonce but since our app is both a tray icon/windows forms app and a Windows Service it appears installing a service via ClickOnce is somewhat unfeasible.
Any suggestions?
To do this update behavior you need two things:
1) An updater application which checks for updates regularly. If an update is found it should install it automatically. Most commercial setup authoring tools include good updater applications. You can try writing an updater yourself, but it's not as easy as it sounds.
2) Per-user installations for each of your product versions. A per-user installation writes data only in the user profile folder (AppData, Roaming folder etc.) and HKEY_CURRENT_USER. No Program Files or HKEY_LOCAL_MACHINE.
Per-user installations are required so you can perform the upgrade silently. If the installation is per machine, newer Windows version will show the elevation prompt and the user won't know what's happening.
The Updater
Some updaters use services. For automated updates this isn't a real solution because service installation needs Administrator privileges. So your install process and subsequent updates would show elevation prompts.
Another approach is to use a per-user Updater application. It doesn't require any elevation and it can be installed in the application folder. This type of updater can run either as a scheduled task or from within your application (execute it when your application starts).
In both scenarios you need to consider that the Updater may need to update itself. So the process which performs the update must be a temporary process (for example a temporary copy of the updater application). It also should run without elevation. This is why a service is not such a good idea. It would need to stop itself before the update, use a temporary process which handles the update and start again when finished.
Here's what I ended up doing for some applications that I manage, and that are written in C#.
I distribute an installer based on InnoSetup to deploy the files on the user system, and the application stores information version in the registry.
The application has a mechanism that checks at startup for available updates, and prompts the user. This system is based on a JSON manifest that contains a basic structure such as the following:
{
"releases": [
{
"CommitDate": "2020-09-05",
"Version": "0.1.0.0",
"VersionString": "0.1.0+19",
"SHA": "4ff750da44b41e569daf3c62f4495a8ee2b25f08",
"InstallerMd5Sum": "805497b5c13ee070b7465bb32689e0dd"
},
{
"CommitDate": "2020-09-07",
"Version": "0.1.0.0",
"VersionString": "0.1.0+22",
"SHA": "a04ec929b21230ba0e2577617713d10b106266e9",
"InstallerMd5Sum": "805497b5c13ee070b7465bb32689e0dd"
}
]}}
The application downloads that file and compares its local information with the latest entry in the file.
If the latest entry is more recent (based on things like commit date), it retrieves the installer from the distribution server, checks for integrity, and run the installer.
The installer takes care of updating the entries in the registry with the latest information.
Now, there are three angles to your question I believe.
The first one is whether a modularity is possible so that you don't end up replacing everything and can provide delta installers, the second is whether you can use a technology that knows how to deal with updates (which I believe MSI knows how to do). Finally, the third angle is whether or not you have a way for users to rollback in case the latest version has issue with their system or whatever your application is for.

WIX non admin Installation

I have an issue regarding wix setup generation, here is my scenario
I have created a setup and tried to install on completion of installation I have done code to create a key in HKCU(H key current user), upto here it is fine.
Now if I try to install with non admin rights then it asked for admin password, then I have entered, installation is completed, problem is the key which I tried to insert in HKCU (Current User) is inserted into the admin account not in the current account where I am installing.
FYI
I am using C# winforms and WIX to generate setup
Any help would be greatly appreciated..
Kind Regards,,
Raghu.M.
You can create an installer that can be executed by non-administrator: https://stackoverflow.com/a/14358274/129269
As mentioned you can no longer install things that require elevated privileges. But on the other hand, when trying to add values to the HKCU my guess is you don't want to install system wide resources.
Update your application to write the default HKCU registry data on first launch. It is much easier than having your setup do the job.
For a description on how you can manage HKCU values after they have been written - in case they need modification, deletion or changing during a reinstall of the application - you can check this thread: http://forum.installsite.net/index.php?showtopic=21552
Thanks for your reply,
This is the way, I approached to solve this.
I have created a component where it inserts key in Local Machine Which will be common for all, and thereby proceed further.
Kind Regards,
Raghu.M

Running application on Startup under different User

I have a .Net app that i install and set to run at Startup. The installer also creates a user that has write permissions to the appropriate application folders and registry sections, preventing the currently running user from modifying the restricted areas.
However, i am unable to figure out how to run the application under a different user. It's not a Service (although that is a possibility). I'm really trying to figure out how to do the following:
Start an application on boot as a different user.
Install a service to start on boot, as a different user.
Can anyone point me in the right direction?
Regards
Tris
With respect to services, you specify the user they run as when you install one.
To start an app as someone else, you could create a batch script that launches your app with the RUNAS command, though I believe you are prompted for a password so it may not be what you're after.

Categories

Resources