App_Offline.htm的目的和意义是可以临时控制网页的应用界面显示与否,这里不再细说。微软为了控制页面,特地设置了此名专门处理屏蔽网页。
这两天,突然看到一个用VBS写的脚本语言如下(关键字段)追加App_Offline.htm代码。
Option Explicit
Dim objWbemLocator
Dim oIIS71
Dim fs
Dim f
Dim dwError
Dim nCopy
Const AP101_NAME = "192.168.131.37"
Const AP101_USER = "192.168.131.37\Administrator"
Const AP101_PASS = "S3300859!"
Const AP101_FROM = "C:\\inetpub\\wwwroot\\SWSK_NEW2\\SWSK_Frame\\SWSK_Frame\\WebSite\\WebFront\\Offline.htm"
Const AP101_TO = "C:\\inetpub\\wwwroot\\SWSK_NEW2\\SWSK_Frame\\SWSK_Frame\\WebSite\\App_Offline.htm"
On Error Resume Next
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set oIIS71 = objwbemLocator.ConnectServer(AP101_NAME, "", AP101_USER, AP101_PASS)
If Err.Number <> 0 Then
dwError = Err.Number
WScript.Quit dwError
End If
nCopy = 0
Set fs = oIIS71.ExecQuery("Select * From CIM_DataFile Where Name = '" & AP101_FROM & "'")
For Each f in fs
dwError = f.Copy (AP101_TO)
nCopy = 1
If dwError <> 0 And dwError <> 10 Then
WScript.Quit dwError
End If
Exit For
Next
If nCopy = 0 Then
WScript.Quit 1 'コピー元ファイルなし
End If
Set fs = Nothing
Set oIIS71 = Nothing
Set objWbemLocator = Nothing
上述代码实现远程Web服务器的目录下追加App_Offline.htm文件,这样正在访问的操作者因为App_Offline.htm的原因,临时操作将会被切换到静态页面
App_Offline.htm中。
反过来,如果要恢复,将将该文件,删除即可。(其实,修改文件名也不失是一种好办法)
这里添加一段,用于删除App_Offline.htm的VBS脚本语言,供参考
Option Explicit
Dim objWbemLocator
Dim oIIS71
Dim fs
Dim f
Dim dwError
Const AP101_NAME = "192.168.131.37"
Const AP101_USER = "192.168.131.37\Administrator"
Const AP101_PASS = "S3300859!"
Const AP101_TO = "C:\\inetpub\\wwwroot\\SWSK_NEW2\\SWSK_Frame\\SWSK_Frame\\WebSite\\App_Offline.htm"
On Error Resume Next
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set oIIS71 = objwbemLocator.ConnectServer(AP101_NAME, "", AP101_USER, AP101_PASS)
If Err.Number <> 0 Then
dwError = Err.Number
WScript.Quit dwError
End If
Set fs = oIIS71.ExecQuery("Select * From CIM_DataFile Where Name = '" & AP101_TO & "'")
For Each f in fs
dwError = f.Delete
If dwError <> 0 Then
WScript.Quit dwError
End If
Exit For
Next
Set fs = Nothing
Set oIIS71 = Nothing
Set objWbemLocator = Nothing