Process[] wyUpdateProcesses = Process.GetProcessesByName("wyUpdate");
foreach (var proc in wyUpdateProcesses){WriteMessage("wyUpdate process was found and killed.");proc.Kill();}
Why are you doing this? It's completely unnecessary and does more harm than good.
Do not pay attention for this. I thought that the reason for the second instance.
What do you mean "it doesn't work"? Exactly what happened? Did you check for updates? What was the output, errors, etc.? Did it succeed? Did you try starting the update? What happens?
Previous version of the method ApplyPatch was
private static void ApplyPatch(string patchFolder) { patchFolder = patchFolder.TrimEnd('\\'); var appFolder = _startupDirectory; var logFile = Path.Combine(appFolder, "wyUpdate.log"); WriteMessage(string.Format("Log file {0}", logFile));
Process.Start(string.Format(@"{0}\wyUpdate.exe", appFolder), string.Format("/fromservice -updatepath=\"{0}\" -logfile=\"{1}\"", patchFolder, logFile)); }
Result: Logfile is empty. Files was not updated.
I tried this version:
private static void ApplyPatch(string patchFolder) { patchFolder = patchFolder.TrimEnd('\\'); var appFolder = _startupDirectory; var logFile = Path.Combine(appFolder, "wyUpdate.log");
WriteMessage(string.Format("Log file {0}", logFile));
Process.Start(string.Format(@"{0}\wyUpdate.exe", appFolder), string.Format("-updatepath=\"{0}\" -logfile=\"{1}\"", patchFolder, logFile)); }
Result: Logfile is empty. Files was not updated.
If I start my console application from cmd.exe it works perfectly. If it runs from scheduled task, wyUpdate does not update files.