How to receive return code in windows service - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

snoppann
Posts: 6
Joined: Sun Jul 04, 2010 5:14 am

How to receive return code in windows service

I've taken the approach of using a windows service to check for updates so admin priv is not required by the end user.

I have /qn on and would like to check for updates and install updates. Here is the code I am using:

System.Diagnostics.ProcessStartInfo processStartInfo =
new System.Diagnostics.ProcessStartInfo(updatepath, "/justcheck");
System.Diagnostics.Process process =
System.Diagnostics.Process.Start(processStartInfo);
process.WaitForExit();
int exit = process.ExitCode;
process.Close();

The problem is that the process never returns by itself. That is it never returns a code to check. This is also true for /silentall.
I'm sure the updatepath is correct and updater + ini are in the same folder as app. The updates work fine when I just click on updater.exe shortcut.

Any clues? Is this the right way to receive the return code from a the updater process triggered inside a service or main app??
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to receive return code in windows service

Hello,
That is it never returns a code to check
What do you mean? What value is the 'exit' variable after the "int exit = process.ExitCode;" line has been evaluated? The code seems correct.
Also, please check using process explorer or the task manager that the updater was started.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
snoppann
Posts: 6
Joined: Sun Jul 04, 2010 5:14 am

Re: How to receive return code in windows service

Ok, I think I'm getting a little closer. My updater service is running as 'local system' so should have full machine rights.

If I run the updater.exe shortcut after I've modified the arguments from /checknow to /silentall and also run as admin then all works fine. I do notice however that /silentall is not truly silent. There is a brief appearance of an "extracting" dialogue before going silent. I wonder if this event is breaking the service's launching of the updater as services cannot interact with the desktop? Any thoughts?
snoppann
Posts: 6
Joined: Sun Jul 04, 2010 5:14 am

Re: How to receive return code in windows service

I'm not sure I can run the updater via a window service as 'Local System'. Local System accounts do not appear to have network privileges. Therefore any process that is launched by the services is run as 'Local System' and cannot download an update. Yuck. What a waste of two weeks.

Has anyone successful used a windows service to run updater and install silentall updates successfully?? :?:
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: How to receive return code in windows service

Hi,

You cannot run updater.exe directly as a Windows service. What you can try is to create a service that invokes the updater.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”