REQUEST A DEMO

Creating IIS7 web applications from the command line

While trying to decide if I should create a Windows Installer for Dovetail Mobile Agent. I was doing some research on how to automate the setup of web applications on IIS7. Turns out it is quite easy from the command line when you are local to the web server using AppCmd.

 

With the helpful batch prowess of of Chad Myers I cooked up this batch file which creates a web application with its own application pool.
@echo OFF
SETLOCAL
SET webSiteName=”Default Web Site”
SET vdir=/mobile
SET physicalPath=C:\projects\mobile\source\Dovetail.Agent.Mobile
SET applicationPoolName=dovetailmobile
SET APPCMD=%SYSTEMROOT%\System32\inetsrv\appcmd.exe

 

%APPCMD% DELETE APPPOOL %applicationPoolName%
%APPCMD% DELETE APP %webSiteName%%vdir%

 

%APPCMD% ADD APPPOOL /name:%applicationPoolName%
%APPCMD% ADD APP /site.name:%webSiteName% /path:%vdir% /physicalPath:%physicalPath% /applicationPool:%applicationPoolName%
ENDLOCAL