當前位置:才華齋>設計>網頁設計>

vbscript自動配置IIS程式碼

網頁設計 閱讀(6.5K)

複製程式碼 程式碼如下:

vbscript自動配置IIS程式碼

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