Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS API - Create virtual directories?

Just looking for the relevant documentation. An example is not necessary, but would be appreciated.

We have a situation where we are having to create 100s of virtual directories manually, and it seems like automating this would be a good way to make the process more efficient for now.

Perhaps next year we can rework the server environment to allow something more sane, such as URL rewriting (unfortunately this does not seem feasible in the current cycle of the web application). Isn't it great to inherit crap code?

~ William Riley-Land

like image 577
wprl Avatar asked Nov 05 '08 17:11

wprl


1 Answers

It is easier to do it with vbscript too..

' This code creates a virtual directory in the default Web Site
' ---------------------------------------------------------------
' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strComputer = "rallen-w2k3"
strVdirName = "<VdirName>"  'e.g. employees
strVdirPath = "<Path>"      'e.g. D:\resumes
' ------ END CONFIGURATION ---------
set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")
set objWebSite = objIIS.GetObject("IISWebVirtualDir","Root")
set objVdir = objWebSite.Create("IISWebVirtualDir",strVdirName)
objVdir.AccessRead = True
objVdir.Path = strVdirPath
objVdir.SetInfo
WScript.Echo "Successfully created virtual directory: " & objVdir.Name
like image 115
Gulzar Nazim Avatar answered Sep 24 '22 01:09

Gulzar Nazim