手机
当前位置:查字典教程网 >脚本专栏 >vbs >vbscript自动配置IIS的代码
vbscript自动配置IIS的代码
摘要:复制代码代码如下:strServerName=""localhost""strRootPath=""g:documents""''虚拟目录路...

复制代码 代码如下:

strServerName=""localhost""

strRootPath=""g:documents""''虚拟目录路径

strVRName=""Test""''虚拟目录名称

strDefaultDoc=""index.asp""''起始文档

DimobjIIS

''MsgBox""IIS://""&strServerName&""/W3SVC/1""

OnErrorResumeNext

SetobjIIS=GetObject(""IIS://""&strServerName&""/W3SVC/1"")

Iferr=-2147024893Then

MsgBox""IIS不存在!""&vbcrlf&""请验证IIS是否已正确安装!"",vbcritical

Wscript.Quit

ElseIferr<>0Then

MsgBox""未知错误!"",vbcritical

Wscript.Quit

EndIf

OnErrorGoTo0

SetobjVirtualDir=objIIS.GetObject(""IISWebVirtualDir"",""Root"")

ForeachVRinobjVirtualDir

IfVR.Name=strVRNameThen

MsgBox""虚拟目录""&strVRName&""已存在!"",vbinformation

Wscript.Quit

EndIf

Next

OnErrorResumeNext

Setfs=Wscript.CreateObject(""Scripting.FileSystemObject"")

SetobjFolder=fs.GetFolder(strRootPath)

Iferr=76Then

MsgBox""路径""&strRootPath&""不存在!"",vbcritical

Wscript.Quit

EndIf

SetobjFolder=nothing

Setfs=nothing

OnErrorGoTo0

OnErrorResumeNext

SetVirDir=objVirtualDir.Create(""IISWebVirtualDir"",strVRName)

VirDir.AccessRead=true

VirDir.Path=strRootPath

VirDir.DefaultDoc=VirDir.DefaultDoc&"",""&strDefaultDoc

VirDir.setInfo

Iferr<>0Then

MsgBox""创建虚拟目录失败!"",vbcritical

Else

MsgBox""虚拟目录""&strVRName&""成功创建在服务器""&strServerName&""上!"",vbinformation

EndIf

代码的关键在于创建虚拟目录,及其中的配置:

SetVirDir=objVirtualDir.Create(""IISWebVirtualDir"",strVRName)

VirDir.AccessRead=true

VirDir.Path=strRootPath

VirDir.DefaultDoc=VirDir.DefaultDoc&"",""&strDefaultDoc

VirDir.setInfo

【vbscript自动配置IIS的代码】相关文章:

用vbs实现将剪切板的unix格式的内容处理成pc格式的代码

vbs 定时删除功能实现代码

用vbs控制iis创建虚拟目录的代码

用VBS修改IIS Metabase 的代码

VBS调用Photoshop批量生成缩略图的代码

运行同一目录下的可执行程序的VBS代码

VBS教程:VBScript 基础-VBScript编码约定

vbs 查找硬盘分区中指定扩展名文件的实现代码

vbs脚本实现批量转换文件编码

校准系统时间的VBS代码

精品推荐
分类导航