IIS管理脚本
1. 列出IIS站点ID、名称、物理路径
2. 修改IIS站点ID
Set ObjService=GetObject("IIS://LocalHost/W3SVC")
For Each obj3w In objservice
If IsNumeric(obj3w.Name) Then
sServerName=Obj3w.ServerComment
Set webSite = GetObject("IIS://Localhost/W3SVC/" & obj3w.Name & "/Root")
ListAllWeb = ListAllWeb & obj3w.Name & String(16-Len(obj3w.Name)," ") & obj3w.ServerComment & vbCrLf
REM & vbCrLf & String(16," ") & "(" & webSite.Path & ")" & vbCrLf
End If
Next
WScript.Echo ListAllWeb
Set ObjService=Nothing
WScript.Quit
For Each obj3w In objservice
If IsNumeric(obj3w.Name) Then
sServerName=Obj3w.ServerComment
Set webSite = GetObject("IIS://Localhost/W3SVC/" & obj3w.Name & "/Root")
ListAllWeb = ListAllWeb & obj3w.Name & String(16-Len(obj3w.Name)," ") & obj3w.ServerComment & vbCrLf
REM & vbCrLf & String(16," ") & "(" & webSite.Path & ")" & vbCrLf
End If
Next
WScript.Echo ListAllWeb
Set ObjService=Nothing
WScript.Quit
2. 修改IIS站点ID
Dim WebService
Dim oldstr
Dim newstr
Dim args
Set args = WScript.Arguments
If args.Count < 1 Then
Wscript.Echo "Must have original instance id and new instance id" & chr(10) & chr(13) & _
"usage: editsiteid.vbs 1 5" & chr(10) & chr(13) & _
"Moves instance 1 to instance 5"
WScript.Quit()
End If
Set WebService = GetObject("IIS://LocalHost/W3SVC")
oldstr = args(0) 'old instance
newstr = args(1) 'new instance
WebService.MoveHere oldstr,newstr
WebService.SetInfo
Set WebService = nothing
Set args=nothing
WScript.echo "DONE"
Dim oldstr
Dim newstr
Dim args
Set args = WScript.Arguments
If args.Count < 1 Then
Wscript.Echo "Must have original instance id and new instance id" & chr(10) & chr(13) & _
"usage: editsiteid.vbs 1 5" & chr(10) & chr(13) & _
"Moves instance 1 to instance 5"
WScript.Quit()
End If
Set WebService = GetObject("IIS://LocalHost/W3SVC")
oldstr = args(0) 'old instance
newstr = args(1) 'new instance
WebService.MoveHere oldstr,newstr
WebService.SetInfo
Set WebService = nothing
Set args=nothing
WScript.echo "DONE"