38

I would like to create a batch file to start one IIS application, and stop another one.

How it can be done using command line?

How to combined it in batch file?

Eugene
  • 1,037
  • 2
  • 12
  • 19
  • For [remote invocations](https://serverfault.com/questions/274831/is-there-a-way-to-make-my-local-appcmd-exe-to-refer-to-a-remote-server/703881#703881) – it3xl Mar 13 '18 at 15:03

1 Answers1

63

http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html

Put this into a file with .bat extension.

@echo off

appcmd start sites "site1"
appcmd stop sites "site2"

Update

Just ensure that appcmd is available anywhere by adding %windir%\system32\inetsrv\ to the PATH environment variable of your system. Alternatively, you can use the full path to appcmd.exe in the batch file.

adarshr
  • 61,315
  • 23
  • 138
  • 167