STRSERVERNAME = "localhost" strrootpath = "g: / documents" '' virtual directory path strvrname = "test" 'Virtual directory name strDefaultdoc = "index.asp"' starting document
Dim objiis' MsgBox "IIS: //" & strServerName & "/ W3SVC / 1"
ON Error ResMe NextSet Objiis = getObject ("IIS: //" & strServerName & "W3SVC / 1")
IIR = -2147024893 THENMSGBOX "IIS does not exist!" & Vbrlf & "Please verify that IIS is installed correctly!"
ON Error Goto 0
Set objVirtualDir = objIIS.GetObject ( "IISWebVirtualDir", "Root") For each VR in objVirtualDirIf VR.Name = strVRName ThenMsgBox "virtual directory" & strVRName & "already exists!", VbinformationWscript.QuitEnd IfNext
On Error Resume NextSet FS = WScript.createObject ("scripting.filesystemObject") set objFolder = fs.getFolder (strrootpath)
IF Err = 76 Then MsgBox "Path" & strrootpath & "Does not exist!", Vbcriticalwscript.quites
Set objFolder = NothingSet FS = Nothingon Error Goto 0
On Error Resume NextSet VirDir = objVirtualDir.Create VirDir.AccessRead = trueVirDir.Path = strRootPathVirDir.DefaultDoc = VirDir.DefaultDoc ( "IISWebVirtualDir", strVRName) & "," & strDefaultDoc
Virdir.setInfo
If Err <> 0 Thenmsgbox "Creates a virtual directory fails!", VbcriticalElsemsGBox "Virtual Directory" & StrvRName & "successfully created in Server" & StrserName & "on!", Vbinformationndiff
The key to the code is to create a virtual directory, and the configuration:
Set VirDir = objVirtualDir.Create ( "IISWebVirtualDir", strVRName) VirDir.AccessRead = trueVirDir.Path = strRootPathVirDir.DefaultDoc = VirDir.DefaultDoc & "," & strDefaultDocVirDir.setInfo
Related resources: with sound access new year fireworks animation effects - html-code