Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have an automated deployment process which is primarily managed by a batch file. One of the first steps in that process is to stop an IIS AppPool so the updated files can be safely copied. To do this, we call PsExec, like this:

PsExec.exe -accepteula %WEB_SERVER_MACHINE_NAME% cmd /c %%systemroot%%\system32\inetsrv\AppCmd.exe stop apppool /"%APP_POOL_NAME%" 2>&1

Where the environment variables are (these are not the actual values, just for illustration):


The entire deployment process usually takes just a few minutes. However, it seems that sometimes, seemingly at random, this process gets stuck at this step and seems to wait indefinitely. If I check the web server during this process, AppPool is not stopped, and manually stopping the AppPool has no effect. There are 6 different sites that need to be deployed and this can happen on any one of the sites.

I have also tried disabling auto-start like this:

PsExec.exe -accepteula %WEB_SERVER_MACHINE_NAME% cmd /c %%systemroot%%\system32\inetsrv\AppCmd.exe set apppool /"%APP_POOL_NAME%" /autoStart:false 2>&1

And occasionally, but it seems to get stalled at this step sometimes. So, it seems to be an issue with PsExec rather than AppCmd. I have also tried specifying a connection timeout to PsExec as well as chaining an exit at the end of the cmd call, like this:

PsExec.exe -accepteula -n 60 %WEB_SERVER_MACHINE_NAME% cmd /c %%systemroot%%\system32\inetsrv\AppCmd.exe stop apppool /"%APP_POOL_NAME%" ^& exit 0 2>&1

Has anyone encountered this issue before? What could cause this PsExec call to stall intermittently?

share|improve this question
up vote 0 down vote accepted

Using WMIC seems more reliable (though not perfect). Here's what I ended up using:

wmic /node:"%WEB_SERVER_MACHINE_NAME%" /namespace:\\root\WebAdministration path ApplicationPool where name='%APP_POOL_NAME%' call start

wmic /node:"%WEB_SERVER_MACHINE_NAME%" /namespace:\\root\WebAdministration path ApplicationPool where name='%APP_POOL_NAME%' set AutoStart=true
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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