iis| Create | Site |iis
' ---------------------------------------------------------------------------
' Creates or deletes the virtual directory Http://localhost/channel7
'
' Valid command line switches:-i-u-Q
'-I Install virtual directory
'-u Remove virtual directory
' Q-Run in quiet mode '
'
' ---------------------------------------------------------------------------
' http://www.microsoft.com/windows2000/en/advanced/iis/default.asp?url=/windows2000/en/advanced/iis/htm/asp/ Aore8v5e.htm
Option Explicit
Dim Vpath,vname, Vwshshell, Vobjargs, Vinstall, Vremove, Vquiet, I
VName = "Channel7"
' Get this path to folder
VPath = Left (Wscript.scriptfullname, InStrRev (wscript.scriptfullname, "\", 15)-1)
VPath = VPath & "\owbase"
' Set WshShell = WScript.CreateObject (' Wscript.Shell ')
' VPath = WshShell.RegRead ("Hklm\software\channel7") & "\owbase"
Vquiet = False
Vinstall = False
Vremove = False
Set Vobjargs = wscript.arguments
For i = 0 to Vobjargs.count-1
If InStr (LCase (Vobjargs (i)), "I") <> 0 Then
Vinstall = True
Elseif InStr (LCase (Vobjargs (i)), "U") <> 0 Then
Vremove = True
End If
If InStr (LCase (Vobjargs (i)), "Q") <> 0 Then
Vquiet = True
End If
Next
If Vremove Then
Deletevdir VName
Elseif Vinstall Then
Createvdir VName, VPath
End If
Sub Createvdir (pname, Ppath)
Dim VRoot, Vbasedir, Vwebsite, Ipsecurityobj, IPList
On Error Resume Next
' Get the local host default Web
Set vwebsite = GetObject ("IIS://LOCALHOST/W3SVC/1")
If not IsObject (vwebsite) Then
Display "Unable to locate" the Default Web Site. IIS must be installed and running. "
Exit Sub
Else
' Display vwebsite.name
End If
' Get the root '
Set vRoot = Vwebsite.getobject ("IIsWebVirtualDir", "Root")
If (Err <> 0) Then
Display "Unable to access root for" & Vwebsite.adspath
Exit Sub
Else
' Display vroot.name
End If
' Find or create ' ow vroot.
' The physical path to Http://localhost/ow are set to the ... <install-dir>\owbase folder
Err.Number = 0 ' Clear Error
Set Vbasedir = GetObject (Vroot.adspath & "/" + pname)
If err.number <> 0 Then
Err.Number = 0
Set Vbasedir = vroot.create ("IIsWebVirtualDir", PName)
Vbasedir.accessread = True
Vbasedir.accessflags = 513 ' = 0x200 + 0x01 = md_access_script + md_access_read
Vbasedir.appcreate False
Vbasedir.aspallowsessionstate = False
Vbasedir.setinfo ' This section restricts access to everyone except localhost (127.0.0.1).
' Set ipsecurityobj = vbasedir.ipsecurity
' Ipsecurityobj.grantbydefault = False
' IPList = ipsecurityobj.ipgrant
' ReDim iplist (UBound (iplist) + 1)
' IPList (UBound (iplist)) = "127.0.0.1"
' Ipsecurityobj.ipgrant = IPList
' vbasedir.ipsecurity = ipsecurityobj
' Vbasedir.setinfo
Vbasedir.path = Ppath
Vbasedir.appfriendlyname = "Channel7"
Vbasedir.setinfo
If (Err <> 0) Then
Display "Un