I have written windows application for managing specific win service. it can start, stop install and uninstall. also i have setup project ( in the same solution of course). the problem is that after i uninstall the application (add/remove programs) the service of course remains in the service list, if the user didn't uninstall before removing whole application.
i've written seperate console application
public static int ExecuteCommand(string Command, int Timeout)
{
int ExitCode;
ProcessStartInfo ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);
Process Process;
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = true;
Process = Process.Start(ProcessInfo);
Process.WaitForExit(Timeout);
ExitCode = Process.ExitCode;
Process.Close();
return ExitCode;
}
static void Main(string[] args)
{
ExecuteCommand(@"sc delete ""bapsi service""", 10000);
Console.WriteLine("BAPSI Service uninstalled...");
//Console.ReadKey();
}
console app works fine, I added all files from release folder to setup file system and placed exe in custom uninstall actions.
However- it doesn't run on uninstall..
is there something else I should do? like adding installer class and some more coding or something.. ?