国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

vbscript自動配置IIS的代碼

2020-07-26 12:05:07
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

strServerName =""localhost""
strRootPath=""g:/documents"" ''虛擬目錄路徑
strVRName=""Test"" ''虛擬目錄名稱
strDefaultDoc=""index.asp"" ''起始文檔

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

On Error Resume Next
Set objIIS=GetObject(""IIS://"" &  strServerName &  ""/W3SVC/1"")

If err=-2147024893 Then
MsgBox ""IIS不存在!"" &  vbcrlf &  ""請驗證IIS是否已正確安裝!"",vbcritical
Wscript.Quit
ElseIf err<>0 Then
MsgBox ""未知錯誤!"",vbcritical
Wscript.Quit
End If

On Error GoTo 0

Set objVirtualDir=objIIS.GetObject(""IISWebVirtualDir"",""Root"")
For each VR in objVirtualDir
If VR.Name=strVRName Then
MsgBox ""虛擬目錄"" &  strVRName &  ""已存在!"",vbinformation
Wscript.Quit
End If
Next

On Error Resume Next
Set fs=Wscript.CreateObject(""Scripting.FileSystemObject"")
Set objFolder=fs.GetFolder(strRootPath)

If err=76 Then 
MsgBox ""路徑"" &  strRootPath &  ""不存在!"",vbcritical
Wscript.Quit
End If

Set objFolder=nothing
Set fs=nothing
On Error GoTo 0

On Error Resume Next
Set VirDir=objVirtualDir.Create(""IISWebVirtualDir"",strVRName)
VirDir.AccessRead=true
VirDir.Path=strRootPath
VirDir.DefaultDoc=VirDir.DefaultDoc &  "","" &  strDefaultDoc

VirDir.setInfo

If err<>0 Then
MsgBox ""創建虛擬目錄失敗!"",vbcritical
Else
MsgBox ""虛擬目錄"" &  strVRName &  ""成功創建在服務器"" &  strServerName &  ""上!"",vbinformation
End If

代碼的關鍵在于創建虛擬目錄,及其中的配置:

Set VirDir=objVirtualDir.Create(""IISWebVirtualDir"",strVRName)
VirDir.AccessRead=true
VirDir.Path=strRootPath
VirDir.DefaultDoc=VirDir.DefaultDoc &  "","" &  strDefaultDoc

VirDir.setInfo


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 类乌齐县| 北票市| 巫山县| 朝阳县| 康平县| 汝州市| 南靖县| 普定县| 治多县| 潜山县| 大同市| 双流县| 崇信县| 勃利县| 蒙自县| 建昌县| 安庆市| 长沙县| 南江县| 平原县| 舞阳县| 凌云县| 娄底市| 桐庐县| 汉沽区| 合江县| 东城区| 麻城市| 赤城县| 扶绥县| 天水市| 叙永县| 弋阳县| 文山县| 华亭县| 永川市| 朝阳市| 阿图什市| 鹤壁市| 吴堡县| 上蔡县|