ASP establishes a virtual Lu directory (ZT)

xiaoxiao2021-03-06  41

'------------------------------------- -------------------------------------------------- 'This function creates a virtual web directory on the specified web site' and with the specified path''mkwebdir [--computer | -c COMPUTER1, COMPUTER2, COMPUTER3] '<- website | -w WEBSITE>' <- virtualdir | -v name1, path1, name2, path2, ...> [--help | -?] '' COMPUTER COMPUTER ON Which Users Exists'Website1, Website2 Virtual Web Sites On Which Director 101, Path1, Name2, Path2 Virtual Directories Names and Paths to create''Example 1 mkwebdir -c mycomputer -w "default web site" "Virtual Dir1", "C: / INETPUB / WWWROOT / DIR1", "Virtual Dir2", " C: / inetpub / wwwroot / dir2 "'" --------------------------------------- -------------------------------------------------- ------------

'Force Explicit Declaration of All Variables.Option Explicit

ON Error ResMe next

Dim Oargs, Argnum

Dim Argcomputer, ArgWebsites, Argvirtualdirs, ArgDirNames (), ArgDirPath (), Dirindexdim ArgComputers

Set ORGS = WScript.ArgumentsArgComputers = Array ("LocalHost")

Argnum = 0while argnum

IF (argnum 1)> = OARGS.COUNT THEN CALL DISPLAYUSAGE END IF

Select Case Lcase (OARGS (Argnum)) Case "- Computer", "- C": argnum = argnum 1 argcomputers = split (OARGS (Argnum), ", -1) Case" --Website "," -w ": argnum = argnum 1 argwebsites = OARGS (argnum) case" --virtualdir "," - v ": argnum = argnum 1 argvirtualdirs = Split (OARGS (Argnum),", ", -1) Case --help ","? "Call Displayusage End Selectargnum = argnum 1WEND

Argnum = 0dirIndex = 0

Redim ArgDirNames (Ubound (Argvirtualdirs) 1) / 2) Redim ArgdirPaths ((Ubound (argvirtualdirs) 1) / 2)

if isArray (ArgVirtualDirs) then While ArgNum <= UBound (ArgVirtualDirs) ArgDirNames (DirIndex) = ArgVirtualDirs (ArgNum) If (ArgNum 1)> UBound (ArgVirtualDirs) Then WScript.Echo "Error understanding virtual directories" Call DisplayUsage End If ArgNum = Argnum 1 argdirpaths (DirIndex) = argvirtualdirs (argnum) argnum = argnum 1 DirIndex = DirIndex 1 Wendend IF

If (ArgWebSites = "") Or (IsArray (ArgDirNames) = False or IsArray (ArgDirPaths) = False) Then Call DisplayUsageElse Dim compIndex for compIndex = 0 to UBound (ArgComputers) Call ASTCreateVirtualWebDir (ArgComputers (compIndex), ArgWebSites, ArgDirNames, ArgDirPaths NEXTEND IF

'------------------------------------- ------------------------------- Sub Display (msg) WScript.echo Now & ". Error Code:" & HEX (ERR) & "-" & Msgend Sub

Sub TRACE (MSG) WScript.echo Now & ":" & msg End Sub

Sub Displayusage () wscript.echo "Usage: mkwebdir [--Computer | -c Computer1, Computer2]" wscript.echo "<- Website | -w Website1>" wscript.echo "<- virtualdir | -v name1, Path1, Name2, Path2, ...> "wscript.echo" [--help | -?] "Wscript.echo" "wscript.echo" Note, Website is The Web site on Which The Directory Will Be created. "WScript "The name can be specified as one of the following:" wscript.echo "Server Number (IE 1, 2, 10, etc." Wscript.echo "Server Description (IE" "My Server "") "WScript.echo" Server Host Name (IE "" www.domain.com ")" WScript.echo "IP Address (IE, 127.0.0.1)" WScript.echo "" WScript.echo "WScript. Echo "Example: mkwebdir -c mycomputer -w" "Default Web Site" "" Dir1 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "c: / inetpub / wwwroot / dir2" ""

WScript.quites Sub '------------------------------------------- ------------------------------------

Sub ASTCreateVirtualWebDir (ComputerName, WebSiteName, DirNames, DirPaths) Dim Computer, webSite, WebSiteID, vRoot, vDir, DirNum On Error Resume Next set webSite = findWeb (ComputerName, WebSiteName) if IsObject (webSite) then set vRoot = webSite.GetObject ( " IisWebvirtualDir "," root ") Trace" Accessing root for "& Website.adspath if (Err <> 0) THEN DISPLAY" UNABLE TO Access Root for "& Website.adspath Else Dirnum = 0 if (Isarray (DirNames) = true) And (IsArray (DirPaths) = True) And (UBound (dirNames) = UBound (DirPaths)) Then While DirNum 0) THEN DISPLAY "Unable to create" & vRoot.adspath & "/" & "else 'set the new version = true vdir.accessRead = true vdir.path = DIRPATHS (DIRNUM) IF (Err <> 0) THEN DISPLAY "Unable to Bind Path" & DirPaths & "To" & VRootname & "/" & Dirna MES (DIRNUM) & "." Else 'Save The Changes Vdir.setInfo IF (Err <> 0) THEN DISPLAY "Unable to save configuration for" & vrootname & "/" & dirnames (dirnum) & " "Else Trace" Web Virtual Directory "& VRootname &" & DirNames (DIRNUM) & "CREATED SUCCESSFULLY." End if End if End if Err = 0 DIRNUM = DIRNUM 1 Wend end if End if else display "

UNABLE TO FIND "& Websitename &" & Computername Endiffing (Bindstr)

Dim One, Two, IA, IP, HN One = IA, IP, HN One = IA (Bindstr, ":") Two = INSTR ((One 1), Bindstr, ":") IA = MID (Bindstr, 1, (One-1))) IP = MID (BindStr, (One 1), ((Two-One) -1)) HN = MID (Bindstr, (Two 1)) getBinding = Array (IA, IP, HN) end function

Function Findweb (Computer, WebName) on Error ResMe Next

DIM WebsVC, Site Dim Webinfo Dim Abinding, Binding

SET WebSVC = GetObject ("IIS: //" & Computer & "IIS: //") IF (Err <> 0) THEN EXIT Function End IF 'First Try To Open The WebName. Set Site = WebSvc.GetObject ("IisWebserver", WebName) IF (Err = 0) and (not isnull (site)) THEN IF (Site.Class = "IisWebserver) THEN 'Here We Found A Site That IS A Web Server. Set Findweb = Site EXIT FUNCTION END IF END IF ERR. clear for each site in websvc if site.class = "IIsWebServer" then '' First, check to see if the ServerComment 'matches' If site.ServerComment = webname Then set findWeb = site exit function End If aBinding = site.ServerBindings if ( Isarray (abinding) "=" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " If if isarray (binding) THEN IF (Binding (0) = WebName) THEN SET FINDWEB = Site EXIT FUNCTION END IF EN D if end if nextend function

转载请注明原文地址:https://www.9cbs.com/read-73304.html

New Post(0)