糯米文學吧

位置:首頁 > 設計 > 網頁設計

vbscript自動配置IIS代碼

複製代碼 代碼如下:

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