Background
I'm trying to automate the creation of Virtual Directories based on the location of an existing Virtual Directory and its sub-directories.
Example:
C:\WebSites\Parent\NewVirtualDirectories
Where Parent is a Virtual Directory and NewVirtualDirectories contains any automated Virtual Directories.
Problem
Using the following Code:
Option Explicit
Dim args, strComputer, strVdirName, strVdirPath, objVdir, objIIS, objWebSite
Set args = WScript.Arguments
strComputer = "localhost"
strVdirName = args(1)
strVdirPath = args(0)
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")
Set objWebSite = objIIS.GetObject("IISWebVirtualDir","Root/Parent")
Set objVdir = objWebSite.Create("IISWebVirtualDir",strVdirName)
objVdir.AccessRead = True
objVdir.Path = strVdirPath
objVdir.AppCreate (True)
objVdir.SetInfo
WScript.Quit
I can create children under Parent, but they show up Directly under the parent. I need them to be in the Sub Folder.
I get: http://localhost/Parent/NewSite
I want: http://localhost/Parent/NewVirtualDirectories/NewSite
I've tried
Set objWebSite = objIIS.GetObject("IISWebVirtualDir","Root/Parent/NewVirtualDirectories")
but NewVirtualDirectories is not a Virtual Directory (an I don't want it to be) so I get an error. I can get the desired effect when I do this manually in IIS manager, but I can't figure out how to automate it.
Any help would be greatly appreciated.