I'm having a problem at the moment deploying and managing windows services and I'm looking for advice on the best course of action.

Here's what I have working (below) - the problem is it's a bit flaky and doesn't always work from my build server and also doesn't give good reasons as why it fails. I generate these commands using nodejs and child_process.

  1. Attempt stop of remote service => (psexec)
  2. Attempt uninstall of remote service => (psexec)
  3. Deploy new code of service => (msdeploy)
  4. Attempt install of remote service => (psexec)
  5. Attempt start of remote service => (psexec)

I'm thinking I should maybe change from using psexec and switch to powershell but I don't have the experience to say one way or the other.

I need solid error codes from running psexec but at the moment I'm not sure how to do it. I could go for a rewrite and ditch psexec in favour of powershell but I don't know if that's the right call or now.

I could try something like psexec \\destination -c stopanduninstall.bat but I'm not sure it that would work better or not and I'm weary of investing too much more time

The other thing I found was https://stackoverflow.com/questions/13844231/batch-file-catching-psexec-result which might work better for catching the errors in the first place and making it more reliable


PSexec is great for quick one-offs, but I wouldn't want to build an infrastructure on it. Powershell, especially with the new Desired State Config, would be a good tool for you to try. Without us knowing barely any of your requirements, only you can answer what you should do.

  • DSC looks great but requires server 2012 r2 which we don't have unfortunately
    – Neil
    Jun 22 '14 at 19:49
  • That would be an important detail/constraint to add into your question. Describe the problem that you are trying to solve, fully.
    – mfinni
    Jun 23 '14 at 1:09
  • 2
    It also looks like that's not correct : DSC is available as part of Windows 8.1 and Windows Server 2012 R2;... If you’re running Windows 7, Windows Server 2008 R2, or Windows Server 2012, install Windows Management Framework 4.0 to get the benefits of DSC. Learn more about how to get started from the DSC documentation on Microsoft TechNet. blogs.msdn.com/b/powershell/archive/2013/11/01/…
    – mfinni
    Jun 23 '14 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.