All processes are forced to stop

I have a hidden GUI that is ran by my main GUI during an update in order for my service to communicate to this hidden GUI to re open the application (since I am forced to use the /fromservice argument for different reasons). However this hidden GUI which does not reference anything, is still asked to be closed during an update. Is there anyway to "skip" a particular process from being closed? (I would think since it does not reference anything it shouldn't have to be closed). Thanks.

Is there anyway to "skip" a particular process from being closed?

No.

(I would think since it does not reference anything it shouldn't have to be closed).

Unfortunately wyUpdate doesn't know that.

Your service could always restart the app instead of a helper app.

Unfortunately can't because the app is a winform and the helper app allows me to have another gui up that can handle reopening the app. The reason why i can not call wyupdate from the original app is because it is running under a limited user account and the service bypasses the elevated permissions prompt. Is there nothing else that can be done to alleviate the issue?

You can run the GUI app from a service, but it's a bit tricky (as you've found). Here's a broad overview of how to do it. If you want I can write a simple example for you. What language is your service in?

All of it is in C#, and using the method from the link you pasted (thanks by the way) will it introduce any other issues? And if it isn't too much trouble I would like a quick example. Thanks again.

[...] will it introduce any other issues?

Nope.

And if it isn't too much trouble I would like a quick example.

Ok, I'll throw something together for you. It might take a few days (I'd do it sooner but I've got a huge backlog of work).

Ok thanks again. Two more quick questions.

Question 1: I am listening to the ReadyToBeInstalled event to show a popup box so that a user can decide whether or not to install the update. If they choose no, and restart the application the box pops up again on startup and if the user clicks yes, the box popups again (a double popup). Is there a reason why the event is thrown twice? (I tried locking the event with a syncroot but it causes a wyUpdate premature exit error)

Question 2: If the user of my application uninstalls the program and re-installs it, the update downloaded seems to still be on the disk somewhere and it pops up the message I mentioned before (even if the current version of my application is higher than the downloaded one and it is bundled with the new version of wyUpdate and client file). With the current version of wyUpdate, is it possible to somehow remove the cache/downloaded update, so that it has to re-download it if indeed the version installed is out of date?

Here's a good start to the code "Subverting Vista UAC in Both 32 and 64 bit Architectures". See the ApplicationLoader.cs file from that article. It's not perfect, but it's a start.

Question 1: I am listening to the ReadyToBeInstalled event [...] if the user clicks yes, the box popups again (a double popup) [...]

ReadyToBeInstalled is called twice. Once when "UpdateStepOn == UpdateDownloaded" and once when "UpdateStepOn == UpdateReadyToInstall". See AutomaticUpdater tutorial for Windows Services and Console Apps.

[...] is it possible to somehow remove the cache/downloaded update, so that it has to re-download it if indeed the version installed is out of date?

Not easily, not yet. We're working to make this easier with wyBuild 2.7.

Thanks guys for your help. I managed to get something working while the example you gave me, thanks. Only thing now is that wyUpdate is throwing two exceptions when starting the GUI from the service. May be only throwing one and the other one is just a result of the first one. Just want to ensure if it is something on my end. Thanks again.

Error 1: System.UnauthorizedAccessException: Access to the path 'wyUpdate AU' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) at wyDay.Controls.AutoUpdaterInfo.GetFilename() at wyDay.Controls.AutoUpdaterInfo..ctor(String auID, String oldAUTempFolder) at wyDay.Controls.AutomaticUpdaterBackend.Initialize() at wyDay.Controls.AutomaticUpdater.System.ComponentModel.ISupportInitialize.EndInit()

Error 2: wyDay.Controls.FailedToInitializeException: You must call the Initialize() function before you can use any other functions. at wyDay.Controls.AutomaticUpdaterBackend.AppLoaded() at wyDay.Controls.AutomaticUpdater.ownerForm_Load(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e)

Error 1: System.UnauthorizedAccessException [...]

Are you starting wyUpdate as a limited process? If so, why? I thought the whole point was to start your app as a limited process. If you start wyUpdate as a limited process from a service then it will fail.

Error 2: wyDay.Controls.FailedToInitializeException

Are you using the Initialize function (like it shows in the example on the AutomaticUpdater tutorial for Windows Services and Console Apps article)? E.g.

// Initialize() and AppLoaded() must be called after events have been set.    // Note: If there's a pending update to be installed, wyUpdate will be    //       started, then it will talk back and say "ready to install,    //       you can close now" at which point your app will be closed.    auBackend.Initialize();    auBackend.AppLoaded();

The process I wanted to restart with the service is running on the user account and not the local system account (hence no admin rights). It works if it is run directly from the start menu but starting it up with the token from the service seems to make wyUpdate throw the exception, so it may just be how the process is being created with the method I wrote. I will try to see what I did wrong. Thanks.

And I just re-read you post and yes I am starting my app from the limited account not wyUpdate. My process is using the autoupdater.

And I followed all the tutorials that were on the website but I can not stop the auto updater from forcing an install on the user. I changed it to CheckAndDownloadOnly but I can not seem to stop it from installing. In the ReadyToInstall event I cased it by update date type and if the update has been downloaded it will do an autoUpdater.InstallNow() and when the download is ready for installation after being downloaded it will show the message and only if the user accepts it will be downloaded. But if I shutdown the computer and restart the process, it forces the install without any message box. Would it probably be better to start the process myself or use the backend? I just want the same level of experience that the autoupdater gives (automatically closing the process, downloading and installing, backing up, then starting the process back up).

EDIT: I wonder if this could be the culprit within the backend source?

internalUpdateType = UpdateType.Automatic;

if (UpdateStepOn == UpdateStepOn.UpdateAvailable) { // begin downloading the update DownloadUpdate(); } else if (UpdateStepOn == UpdateStepOn.UpdateDownloaded) { ExtractUpdate(); } else // UpdateReadyToInstall { // begin installing the update InstallPendingUpdate();

Sorry for all the questions but may as well ask them while I got you here 🙂.

My process is using the autoupdater.

So you're using both wyUpdate from a service & the AutomaticUpdater from your user-level app? This is the problem. Do one or the other. Don't do both.

If you just want to do simple checking for updates on the GUI side of things (and you don't want to write the IPC from your service to your app) then see this article: How to Silently Check for Updates.

Leave the updating to your service.

No that isn't how it is now. Sorry I will explain my layout exactly. I have two types of systems, one software system is the parent -> consists of a service and a winform; the other is a child -> consists of a main service, an update service, and a winform.

The parent system's winform only works whenever the user has ran it as an administrator. So from this system I use the automatic updater since its permissions are already elevated, it does not update from the service. When using the automatic updater if the user cancels the update, on the next run of the winform it forces the install (even though I have the checks in to always make sure the user accepts before continuing), which I don't want, so I was wondering which other method could I use to update but keeping the wyUpdate GUI that shows the process of the update and that automatically restarts the winform after its done.

The child's system is never elevated so it get's permission from the parent (using wcf beyond the scope of the problem) and when the parent allows the update the child's updater service is started (runs on the local system account). What I wanted it to do here was start wyUpdate from the command line with the /fromservice argument. Then after it was done it would restart the update service with an argument in which the service would use CreateProcessAsUser to start the GUI from the service. That is when wyUpdate gives the UnauthorizedAccessException. If I launch the GUI with elevated permissions with CreateProcessAsUser it works fine, but if I try to launch the GUI from the current user (with limited permissions) wyUpdate gives the error. So I just wanted to make sure it was not something on wyUpdate's end before going deeper into the method I wrote from starting the GUI process.

Thanks for your time. Hope that clears it up. 😀

Just an update I decided to schedule a task in the task scheduler before closing the child's GUI and that seems to work fine. The only issue now is with the parent being forced to install an update.