Creating applications with adsutil.vbs

There's lots of information out there on how to create a virtual directory in IIS with adsutil.vbs. But when you need an application, like for an ASP.NET website, you need one more step which I had some trouble finding.

Adsutil.vbs is a script to manage IIS from the commandline. If you're using IIS6 you can use other scripts like iisvdir.vbs and iisweb.vbs. But for IIS5, these aren't available, so you have to use adsutil.vbs instead.

Here's the three commands necessary:

cscript %SystemDrive%\Inetpub\AdminScripts\AdsUtil.vbs create w3svc/1/root/myApp "IisWebVirtualDir"

cscript %SystemDrive%\Inetpub\AdminScripts\AdsUtil.vbs appcreateinproc w3svc/1/root/myApp

cscript %SystemDrive%\Inetpub\AdminScripts\AdsUtil.vbs set w3svc/1/root/myApp\path "D:\MyWebsite"

The first step creates a virtual directory under IIS. The virtual directory is named 'myApp' in this case and is of the keytype 'IisWebVirtualDir' (I haven't found a resource on keytypes yet, so it's the only type I know).

The second step creates an (in process) application from that virtual directory.

The last step sets the path to content somewhere on the filesystem.

After that, the site is accessible through http://localhost/myApp.