Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9049265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:21:17+00:00 2026-06-16T12:21:17+00:00

Ok, this is what I want to do – We have a windows service

  • 0

Ok, this is what I want to do –

We have a windows service and we want to automate deployment of this service to the test environments after every successful CI build – for this we thought of the following approach –

  • Build the Windows Service project (along with dependencies)
  • Stop the windows service
  • Copy the project output from the output folder to the Windows Service file-path
  • Start the service

However, currently I am facing problems with the starting and stopping of the windows service.

This is the MSBuild snippet –

<!-- TODO: do this using Powershell instead of normal commandline so that it can be executed on remote machines as well -->
<Exec Command="Net Stop CreditProcessing" />
<!-- Exec Command="$(PowerShellExe) -NoProfile -Noninteractive -command &quot;&amp;{ Stop-Service CreditProcessing }&quot;" /-->

<!-- TODO: The destination needs to come from the env variable or rsp file? -->
<Copy 
    SourceFiles="@(WindowsServiceFilesToDeploy)" 
    DestinationFiles="@(WindowsServiceFilesToDeploy->'D:\WindowsServices\Credit Processing Service%(RecursiveDir)%(Filename)%(Extension)')" />  

<Exec Command="Net Start CreditProcessing" />   
<!--Exec Command="$(PowerShellExe) -NoProfile -Noninteractive -command Start-Service CreditProcessing" /--> 

This I tried with both direct command line commands as well as powershell commands.

A) This is the problem I face when I try to run this build with normal commands – the service takes some time to start/stop and the build doesn’t wait long enough and reports an error and stops

“… service could not be started”.
“Service did not report an error”

or sometimes when stopping

“The service could not be controlled in its present state.”

whereas if we immediately check the services it will be in “Starting” stage and soon it will go to “Start” stage. Any way to make the build be a little more patient? The command doesn’t do this if run directly from command prompt.

B) This is the problem we face if I use the above powershell commands (currently commented in the snippet) –

It just opens the powershell prompt in the build log and then just does nothing
Build stops at powershell doesn't continue

Can you help avoid these problems (at least one of these)? I think the powershell route is more recommended if it works fine, but I’m open to suggestions.

A couple of other questions –

  • We want to deploy the service (and hence stop and restart) on a remote machine (other than where this CI build is happening) – anyway this can be done?

  • Is there a way to add a check whether the service is already running and stop only if it is running? If it is stopped and we try to stop again, it will give “Service not started” error

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:21:18+00:00Added an answer on June 16, 2026 at 12:21 pm

    Your command to launch is of this form:

    path\to\powershell.exe
    -arg1 -arg2
    

    The newline means that PowerShell never receives the arguments, so doesn’t know it has to execute a Start-Service command, and doesn’t know you don’t want it to be interactive. It’s probably just waiting for you to tell it what to do.

    Check your $(PowerShell) variable, as it probably has a newline at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I only want this function to run if .toolbar li does not have the
I want this usercontrol to be Created via MEF but also to have the
This is what I want: This is what I have done: The difference is
I want this box to go up and down just like I have it
I want this link to have a JavaScript dialog that asks the user Are
I want this : I am building a few screens where I will have
I want this: And I thought that passing na.action=na.pass to boxplot would let NA
I want 'This Is A 101 Test' to be 'This Is A Test', but
I want to apply this while loop into the for loop below. I have
How do I get and print a char from a user? This want do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.