Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   Creating Sites and Virtual Directories, and Setting Properties Using WMI (http://forum.oszone.net/showthread.php?t=218516)

kasemsot 21-10-2011 02:11 1778288

Creating Sites and Virtual Directories, and Setting Properties Using WMI
 
Добрый день!

Следущий вопрос к знатокам. Есть задача создать виртуальный каталог на IIS и настроить его свойства. Под эту задачу идеально подходит данный сценарий для VBScript, но с моими знаниями портировать его на AutoIt мне не удалось.
Компилятор ругается на Array (0) и на поле vdirObj.DirBrowseFlags = &H4000003E, в частности на символ & в начале значения переменной.

Весь инет перерыл, ничего не нашел. Может кто поможет перевести данный скрипт на язык AutoIt, буду очень признателен.

Заранее спасибо. Вот сценарий с сайта майкрософт:

Код:

' Make connections to WMI, to the IIS namespace on MyMachine, and to the Web service.
set locatorObj = CreateObject("WbemScripting.SWbemLocator")
set providerObj = locatorObj.ConnectServer("MyMachine", "root/MicrosoftIISv2")
set serviceObj = providerObj.Get("IIsWebService='W3SVC'")
 
' Build binding object, which is a required parameter of the CreateNewSite method.
' Use the SpawnInstance WMI method since we are creating a new instance of an object.
Bindings = Array(0)
Set Bindings(0) = providerObj.get("ServerBinding").SpawnInstance_()
Bindings(0).IP = ""
Bindings(0).Port = "8383"
Bindings(0).Hostname = ""
 
' Create the new Web site using the CreateNewSite method of the IIsWebService object.
Dim strSiteObjPath
strSiteObjPath = serviceObj.CreateNewSite("MyNewSite", Bindings, "C:\Inetpub\Wwwroot")
If Err Then
WScript.Echo "*** Error Creating Site: " & Hex(Err.Number) & ": " & Err.Description & " ***"
WScript.Quit(1)
End If
 
' strSiteObjPath is in the format of IIsWebServer='W3SVC/1180970907'
' To parse out the absolute path, W3SVC/1180970907, use the SWbemObjectPath WMI object.
Set objPath = CreateObject("WbemScripting.SWbemObjectPath")
objPath.Path = strSiteObjPath
stLrSitePath = objPath.Keys.Item("")
 
' Set some properties on the root virtual directory which was created by CreateNewSite.
Set vdirObj = providerObj.Get("IIsWebVirtualDirSetting='" & strSitePath & "/ROOT'")
vdirObj.AuthFlags = 5 ' AuthNTLM + AuthAnonymous
vdirObj.EnableDefaultDoc = True
vdirObj.DirBrowseFlags = &H4000003E ' date, time, size, extension, longdate
vdirObj.AccessFlags = 513 ' read, script
vdirObj.AppFriendlyName = "Root Application"
 
' Save the new settings to the metabase
vdirObj.Put_()
 
' CreateNewSite does not start the server, so start it now.
Set serverObj = providerObj.Get(strSiteObjPath)
serverObj.Start
 
WScript.Echo "A New site called MyNewSite was created with the path and unique site identification number of " & strSitePath



Время: 08:49.

Время: 08:49.
© OSzone.net 2001-