VBScript: create IIS virtual directory with content redirection
Option Explicit
On Error Resume Next
Dim ServObj
Dim VdirObj
Dim VdirName
Dim VdirPath
Dim VdirResourceContent
VdirName = wscript.arguments(0)
VdirPath = wscript.arguments(1)
VdirResourceContent = wscript.arguments(2) & “,EXACT_DESTINATION”
Set ServObj = GetObject(“IIS://LocalHost/w3svc/1/Root”)
if (Err 0) then
wscript.quit
end if
Set VdirObj = ServObj.Create(“IIsWebVirtualDir”, VdirName)
VdirObj.SetInfo
if (Err0) then
wscript.quit
end if
VdirObj.AccessRead = True
VdirObj.AccessScript = True
VdirObj.Put “Path”, (VdirPath)
VdirObj.Put “HttpRedirect”, VdirResourceContent
VdirObj.SetInfo
if (Err 0) then
wscript.quit
end if
wscript.echo “Virtual directory successfully created”