title: How to uninstall Windows service using Custom Uninstaller
body: <p>We have many questions on stackoverflow regarding uninstallation of Windows Service.<br/> After trying all of them I still fail to uninstall the windows service on new version Installation.</p>
  
  <p>I use setup and deployment project to install/uninstall my project which has a windows service and some other projects.</p>
  
  <p>During installation of newer version, all other projects are successfully re-installed but windows service project fails to Re-install and says: </p>
  
  <blockquote>
    <p>Error 1001: The specified service already exists.</p>
  </blockquote>
  
  <p>I referred <a href="https://stackoverflow.com/questions/451573/how-do-i-eliminate-the-specified-service-already-exists-when-i-install-new-vers/617385#617385">this link</a> and tried to add code to my Install custom action to Stop the service.  If I understood the answer in this link correctly, I have put the code to stop the service inside projectInstaller.cs file of the Service:</p>
  
  <pre><code>public override void Install(IDictionary stateSaver)
  { 
        ServiceController sc = new ServiceController("SareeManagerNotifications");
        if (sc.Status == ServiceControllerStatus.Running)
            sc.Stop();
       base.Install(stateSaver);
  }
  </code></pre>
  
  <p>Custom action pane looks like:
  <img src="https://i.stack.imgur.com/9nXPp.png" alt="enter image description here"></p>
  
  <p>Where the highlighted part is the Service.</p>
  
  <p>I also went through <a href="http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/bedbb8bd-dad5-4bcb-a87a-ac69386669b4/" rel="nofollow noreferrer">this answer</a> which says to set custom action condition as <br/><code>NOT PREVIOUSVERSIONSINSTALLED</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/kRucP.png" alt="enter image description here"></p>
  
  <p>This doesn't work for me. Where am I going wrong ?</p>
  
  <p>Thanks in advance :)</p>