title: Pre/Post build event for windows service. Best practice
body: <p>Got a windows service and need to recreate it with project build.</p>
  
  <p><strong>In pre event:</strong></p>
  
  <blockquote>
    <p>sc query "Service" | findstr /i running | if "%errorlevel%"=="0" (sc
    stop "Service")</p>
    
    <p>sc query "Service" | findstr /i running | if "%errorlevel%"=="0" (sc
    delete "Service")</p>
  </blockquote>
  
  <p><strong>In post event:</strong></p>
  
  <blockquote>
    <p>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe
    $(TargetPath)</p>
    
    <p>net start "Service"</p>
  </blockquote>
  
  <p>but i have issues like </p>
  
  <blockquote>
    <p>Error 1   The command
    "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe
    D:...\bin\Debug\Host.exe</p>
    
    <p>net start "Service" " exited with code 2. Host</p>
  </blockquote>
  
  <p>any help, please?</p>