Создание сайта в IIS

Option Explicit 
'On Error Resume Next
Dim strComputer
dim wmiNS
Dim siteName 
Dim strSiteObjPath
Dim locatorObj
Dim providerObj
Dim objPath
Dim vDirObj
Dim serverObj
Dim serviceObj
Dim bindings
Dim strSitePath

strComputer = "London"
wmiNS = "root/MicrosoftIISv2"
siteName = "LondonWebSite"

set locatorObj = CreateObject("WbemScripting.SWbemLocator")
set providerObj = locatorObj.ConnectServer(strComputer, wmiNS)
set serviceObj = providerObj.Get("IIsWebService='W3SVC'")
Set objPath = CreateObject("WbemScripting.SWbemObjectPath")

Bindings = Array(0)
Set Bindings(0) = providerObj.get("ServerBinding").SpawnInstance_()
Bindings(0).IP = ""
Bindings(0).Port = "8383"
Bindings(0).Hostname = ""

strSiteObjPath = serviceObj.CreateNewSite(siteName, Bindings, "C:\Inetpub\Wwwroot")
objPath.Path = strSiteObjPath
strSitePath = objPath.Keys.Item("")
	subCheckErrors

	subSetProperties
	
	subStartTheSite

WScript.Echo "Created " & siteName
WScript.Echo "The path/ID is " & strSitePath

Sub subCheckErrors
If Err Then
WScript.Echo "Error: " & Hex(Err.Number) _
 & ": " & Err.Description
WScript.Quit(1)
End If
End Sub

Sub subSetProperties
Set vdirObj = providerObj.Get("IIsWebVirtualDirSetting='" & strSitePath & "/ROOT'")
vdirObj.AuthFlags = 5 
vdirObj.EnableDefaultDoc = True
vdirObj.DirBrowseFlags = &H4000003E 
vdirObj.AccessFlags = 513 
vdirObj.AppFriendlyName = "Root Application"
vdirObj.Put_()
End Sub

Sub subStartTheSite
Set serverObj = providerObj.Get(strSiteObjPath)
serverObj.Start
End Sub 
Интересное на сайте: 
0
Голосов пока нет

Оставить комментарий