0

I have a Worker Service which has an auto-update feature. Whenever there is an update available it needs to call an Installer.exe in administrator mode which is a console application (Project Referenced). Whenever I Run Intaller.exe as a standalone console app, it does its work but when it is called from worker service it doesn't even get invoked.

The way I know it doesn't work is the first task of the Installer app is to stop the worker service, but it doesn't stop.

I tried including app.manifest in Installer.exe and Worker Service both, to run them as Administrator but that didn't change a thing.

This is how I am calling the Installer App.

string installerPath = Directory.GetCurrentDirectory() + @"\" + "Installer.exe";
Log.Debug("Installer Path: {0}", installerPath);
var installProcess = new ProcessStartInfo();
installProcess.FileName = installerPath;
installProcess.CreateNoWindow = false;
installProcess.WindowStyle = ProcessWindowStyle.Normal;
installProcess.UseShellExecute = true;
installProcess.Verb = "runas";

Log.Debug("Update process started.This service will shutdown now.");
var process = Process.Start(installProcess);
process.WaitForExit();
process.Close();

What am I doing wrong here? Or is it not possible to do this?

rcode
  • 23
  • 5
  • Does this help? https://stackoverflow.com/questions/7666408/how-to-request-administrator-permissions-when-the-program-starts – Dominik Viererbe Nov 03 '21 at 10:51
  • Side Note: Let the Installer wait for the Worker to exit on it's own. This ensures that the worker is not interrupted during an important task. – Dominik Viererbe Nov 03 '21 at 10:55
  • I also don't see how your Application is shutting itself down. `process.WaitForExit();` will block the thread of the worker service until the Installer process has exited – Dominik Viererbe Nov 03 '21 at 10:57
  • @DominikViererbe Installer.exe calls a batch file. whose first command is to stop the worker service. but the batch file doesn't get executed. – rcode Nov 09 '21 at 04:53

0 Answers0