Using c#. Hopefully its clear enough if you're doing something else.I need a lot of control over updates so I'm using the command line version as follows. I also feed in the download location etc
downloadaddress = something like "http://mysite.com/myupdatefiles"updatepath = something like "http://mysite.com/myupdatefiles/app1updatefiles"serverpath = something like "http://mysite.com/myupdatefiles/app1updatefiles/wyserver.wys"updaterexecutable="W:\Projects\myapp.root\myapp\myappmain\bin\Debug\wyupdate.exe"
public bool ReadyForUpdate() { string downloadAddress, updatePath, serverPath, updaterExecutable; GetLocations(out downloadAddress, out updatePath, out serverPath, out updaterExecutable); string arguments = string.Format(@"-server=""{0}"" -updatepath=""{1}"" /quickcheck /justcheck /noerr /outputinfo", serverPath, updatePath); // Generate the command var startInfo = new ProcessStartInfo { RedirectStandardOutput = true, CreateNoWindow = true, FileName = updaterExecutable, // Need to set the base directory. Perform a check to see if version has changed Arguments = arguments, UseShellExecute = false };
// Run the process using (var process = new Process { StartInfo = startInfo }) { if (!process.Start()) throw new Exception(DatabaseResources.Was_unable_to_start_the_update_application);
// Wait 30 secs for it to exit var sbOutput = new StringBuilder(); var timeEnd = DateTime.Now.AddSeconds(30); while (!process.HasExited) { sbOutput.Append(process.StandardOutput.ReadToEnd()); if (DateTime.Now > timeEnd) break; } sbOutput.Append(process.StandardOutput.ReadToEnd()); var outputMsg = sbOutput.ToString().Trim();
if (!process.HasExited) throw new Exception(DatabaseResources.ReadyForUpdate_Timed_out_waiting_for_the_updating_process_to_exit);
switch (process.ExitCode) { case 0:// No update available return false; case 2:// Update available return true; default:// error { if (!string.IsNullOrWhiteSpace(outputMsg)) throw new Exception(outputMsg); throw new Exception(DatabaseResources.There_was_an_undefined_error_whilst_attempting_to_query_the_update_server_Please_try_again); } } } }