IIS 6.0 help

Nosaj

Senior member
Sep 11, 2002
336
0
0
I need to create hundreds of frontpage 2002 extended subwebs, (each with their own administrators or advanced authors) in IIS 6.0 for corporate users.

I have a script that creates the folders on the drive, sets permissions and then adds them as a virtual directory.

How can I efficiently create these subwebs? I am sure that it can be scripted, but I cannot find any resources.

Thanks.
 

Nosaj

Senior member
Sep 11, 2002
336
0
0
It took me all day, but I figured it out. Here is the script that I created/pieced together:

set wshshell = CreateObject("WScript.Shell")
set wshnet = CreateObject("WScript.Network")

Const ForReading = 1
Const SERVERS = "c:\users.txt"

Dim Root
Dim Dir
Dim fso, f
Dim arrText()
Dim iUpperBound


Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(SERVERS, ForReading)


' ****************************
'Read the file line by line, and add each line to the array.

iUpperBound = 0
While Not f.AtEndOfStream
ReDim Preserve arrText(iUpperBound)
arrText(UBound(arrText)) = f.ReadLine
iUpperBound = iUpperBound + 1
Wend

f.Close
'*****************************

'******************************************************************
'* For each user in c:\users.txt, create folder, set permissions, *
'* and create virtual directory for website. *
'******************************************************************
For Each elem In arrText

'*** create the folder ***
Set fso = CreateObject("Scripting.FileSystemObject")
FSO.CreateFolder("d:\home\" & elem)


'*** create virtual directory ***
Set Root = GetObject("IIS://LocalHost/W3SVC/1/ROOT")
if (Err.Number <> 0) then
MsgBox "Web Server doesn't exist"
wscript.Quit
end if
Set Dir = Root.Create("IIsWebVirtualDir", elem)
Dir.Path = "d:\home\" & elem
Dir.AccessRead = True
Dir.AccessWrite = False
Dir.EnableDirBrowsing = False
Dir.AppFriendlyName = elem
Dir.SetInfo
Set Dir = Nothing
Set Root = Nothing


'*** create FP extended subweb ***
strowsadm = "cmd /c owsadm.exe -o create -w /" & elem & " -m 1"
Set objWSH = CreateObject("WScript.Shell")
objrtc = objwsh.run (strowsadm, 0, true)
'objwsh = nothing


'*** set fp subweb permissions (user as admin) ***
Set objWSH = CreateObject("WScript.Shell")
strowsadm = "cmd /c owsadm.exe -o userroles -c add -u d7\" & elem & " -n Admin -m 1 -w /" & elem & " -o setperms -w /" & elem & " -i false"
objrtc = objwsh.run (strowsadm, 0, true)
'objwsh = nothing

Set objWSH = CreateObject("WScript.Shell")
strowsadm = "cmd /c owsadm.exe -o userroles -c add -u d7\" & elem & " -n Admin -m 1 -w /" & elem
objrtc = objwsh.run (strowsadm, 0, true)
'objwsh = nothing


'*** Set Change Permissions for the user using CACLS.exe ***
strACLCommand = "cmd /c echo y|cacls d:\home\" & elem & " /t /e /g " & elem & ":F"
Set objWSH = CreateObject("WScript.Shell")
objRTC = objWSH.Run (strACLCommand , 0, True)
Set objWSH = Nothing

Next

'*** end loop ***
wscript.echo "All Webfolders Completed"
wscript.quit