did you find a solution to this issue? we are facing similar issues on the update phase rather than the check phase
Hi,
I have been unsuccessful in getting the check for updates to return 2 when calling the check function from within a Windows Service. The same check function returns 0 when called within the service and 2 when called from a console/winforms project or command prompt.
The update is found in either case because the description of the update is returned and logged. It's only the process exit code that is not being returned to the WindowsService.
Here is the function:
public void PerformCheck(bool StartUp, UpdateAssembly updateAssembly, Gurock.SmartInspect.Session logger) { siLogger = logger; string proggy = Path.Combine(Application.StartupPath, "wyupdate.exe"); // AquaCommUpdater.exe"); if(!File.Exists(proggy)) { siLogger.LogError("{0} file does not exist!", proggy); return; } string wyUpdateCfg = ""; switch (updateAssembly) { case UpdateAssembly.MCDBManager: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcdbmanagerClient.wyc"); updatingProgram = "MCDBManager"; break; case UpdateAssembly.MCDBService: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcdbserviceClient.wyc"); updatingProgram = "MCDBService"; isService = true; break; case UpdateAssembly.MCManager: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcmanagerClient.wyc"); updatingProgram = "MCDBService"; break; case UpdateAssembly.MCService: wyUpdateCfg = "mcserviceClient.wyc"; updatingProgram = "MCService"; isService = true; break; case UpdateAssembly.MCSupport: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcsupportClient.wyc"); updatingProgram = "MCSupport"; break; case UpdateAssembly.MyCourtsAdmin: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcadminClient.wyc"); updatingProgram = "MyCourtsAdmin"; break; case UpdateAssembly.MyCourtsMaintenance: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcmaintClient.wyc"); updatingProgram = "MyCourtsMaintenance"; break; case UpdateAssembly.MyCourtsUI: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcuiClient.wyc"); updatingProgram = "MyCourtsUI"; break; case UpdateAssembly.MyCourtsUpdate: wyUpdateCfg = Path.Combine(Application.StartupPath, "mcupdateClient.wyc"); updatingProgram = "MyCourtsUpdate"; break; } if (!File.Exists(wyUpdateCfg)) { string args = string.Format("/quickcheck /justcheck /noerr /outputinfo -cdata=\"{0}\"", wyUpdateCfg); string[] data = new string[] { proggy, args }; siLogger.LogMessage("Executing {0} {1}", data); int returnCode = 9; try { var process = new Process { StartInfo = new ProcessStartInfo { WorkingDirectory = Application.StartupPath, FileName = proggy, Arguments = args, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true, ErrorDialog = false, WindowStyle = ProcessWindowStyle.Hidden } };
process.Start(); updateInformation = new StringBuilder(); updateInformation.AppendLine("Updates available in Version "); int lineNumber = 0; while (!process.StandardOutput.EndOfStream) { var line = process.StandardOutput.ReadLine(); if (lineNumber == 0) { siLogger.LogString("StandardOutput", line); updateInformation.Append(line); } else { lineNumber++; updateInformation.AppendLine(line); siLogger.LogString("StandardOutput", line); } } if (lineNumber > 0) siLogger.LogString("updateInformation", updateInformation.ToString()); process.WaitForExit(90000); returnCode = process.ExitCode; siLogger.LogInt("wyUpdate.exe returned an exit code of ", process.ExitCode); } catch (Exception ex) { siLogger.LogException("Check for Updates failed", ex); } if (returnCode == 0) { if (!StartUp) siLogger.LogMessage("No updates were found."); } if (returnCode == 2) { siLogger.LogMessage("Updating application"); if (isService) args = string.Format("/fromservice /outputinfo -cdata=\"{0}\"", wyUpdateCfg); else args = string.Format("/outputinfo -cdata=\"{0}\"", wyUpdateCfg); try { var process = new Process { StartInfo = new ProcessStartInfo { WorkingDirectory = Application.StartupPath, FileName = proggy, Arguments = args, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true, ErrorDialog = false, WindowStyle = ProcessWindowStyle.Hidden //UseShellExecute = true //RedirectStandardOutput = true, //CreateNoWindow = false } }; process.Start(); ExitApp = true;
while (!process.StandardOutput.EndOfStream) { var line = process.StandardOutput.ReadLine(); siLogger.LogString("StandardOutput", line); } returnCode = process.ExitCode; siLogger.LogInt("Updater returned", process.ExitCode); } catch (Exception ex) { siLogger.LogException("Install Updates failed", ex); } }
if(returnCode == 9) { siLogger.LogError("The process did not complete!"); } } else { siLogger.LogError("Clent.wyc file {0} doesn't exist!", wyUpdateCfg); } }
did you find a solution to this issue? we are facing similar issues on the update phase rather than the check phase