复制代码 代码如下:
strServerName=""localhost""
strRootPath=""g:documents""'虚拟目录路径
strVRName=""Test""'虚拟目录名称
strDefaultDoc=""""'起始文档
DimobjIIS
'MsgBox""IIS://""&strServerName&""/W3SVC/1""
OnErrorResumeNext
SetobjIIS=GetObject(""IIS://""&strServerName&""/W3SVC/1"")
Iferr=-2147024893Then
MsgBox""IIS不存在!""&vbcrlf&""请验证IIS是否已正确安装!"",vbcritical
ElseIferr<>0Then
MsgBox""未知错误!"",vbcritical
EndIf
OnErrorGoTo0
SetobjVirtualDir=bject(""IISWebVirtualDir"",""Root"")
ForeachVRinobjVirtualDir
=strVRNameThen
MsgBox""虚拟目录""&strVRName&""已存在!"",vbinformation
EndIf
Next
OnErrorResumeNext
Setfs=teObject(""SystemObject"")
SetobjFolder=older(strRootPath)
Iferr=76Then
MsgBox""路径""&strRootPath&""不存在!"",vbcritical
EndIf
SetobjFolder=nothing
Setfs=nothing
OnErrorGoTo0
OnErrorResumeNext
SetVirDir=te(""IISWebVirtualDir"",strVRName)
ssRead=true
=strRootPath
ultDoc=ultDoc&"",""&strDefaultDoc
nfo
Iferr<>0Then
MsgBox""创建虚拟目录失败!"",vbcritical
Else
MsgBox""虚拟目录""&strVRName&""成功创建在服务器""&strServerName&""上!"",vbinformation
EndIf
代码的关键在于创建虚拟目录,及其中的配置:
SetVirDir=te(""IISWebVirtualDir"",strVRName)
ssRead=true
=strRootPath
ultDoc=ultDoc&"",""&strDefaultDoc
nfo