共用方式為


ConfigurationHistorySection 類別

設定 ApplicationHost 協助程式服務的組態歷程記錄設定。

Syntax

class ConfigurationHistorySection : ConfigurationSection  

方法

下表列出 類別所 ConfigurationHistorySection 公開的方法。

名稱 描述
GetAllowDefinition (繼承自 ConfigurationSection.)
GetAllowLocation (繼承自 ConfigurationSection。)
RevertToParent (繼承自 ConfigurationSection。)
SetAllowDefinition (繼承自 ConfigurationSection。)
SetAllowLocation (繼承自 ConfigurationSection。)

屬性

下表列出 類別所 ConfigurationHistorySection 公開的屬性。

名稱 描述
Enabled 讀取/寫入 boolean 值。 true 如果 ApplicationHost 協助程式服務會使用 屬性所 Period 指定的時間間隔來檢查ApplicationHost.config檔案中的變更,則為 ; false 如果服務未檢查變更,則為 。 預設值為 true。 如果組態變更且仍然有效,協助程式服務會將ApplicationHost.config檔案儲存在 屬性所 HistoryPath 指定目錄內的已建立版本的子目錄中。
HistoryPath 讀取/寫入 string 值,指定包含組態歷程記錄子目錄之目錄的路徑。 預設值為 「%systemdrive%\inetpub\history」。 注意: ApplicationHost 協助程式服務會在每個組態歷程記錄子目錄中儲存一份ApplicationHost.config檔案。 組態歷程記錄子目錄具有命名格式CFGHISTORY_< 數 >。 序號是 10 位數的序號, (零填補) 。
Location (繼承自 ConfigurationSection .) 金鑰屬性。
MaxHistories 讀取/寫入 uint32 值,指定組態歷程記錄子目錄的最大數目。 預設值為 10。 如果組態歷程記錄子目錄的數目達到指定的數目,則會刪除具有最低版本號碼的子目錄。
Path (繼承自 ConfigurationSection .) 金鑰屬性。
Period 讀取/寫入 datetime 值,指定 ApplicationHost 協助程式服務檢查ApplicationHost.config檔案中變更的頻率。 預設值為 2 分鐘。 如果組態變更且仍然有效,協助程式服務會將檔案儲存在 屬性所 HistoryPath 指定的目錄中。
SectionInformation (繼承自 ConfigurationSection。)

子類別

這個類別不包含子類別。

備註

這個類別提供組態歷程記錄功能,可讓您在不再需要目前狀態時返回先前的設定狀態。

ApplicationHost 協助程式服務藉由儲存ApplicationHost.config檔案來分隔屬性所 Period 指定之設定間隔的組態歷程記錄子目錄,藉此啟用設定歷程記錄功能。 子目錄位於 屬性所 HistoryPath 指定的目錄中。

如果您在修改ApplicationHost.config檔案時發生錯誤,可以將舊版的檔案從組態歷程記錄子目錄中還原,方法是將舊版複製到 %windir%\system32\inetsrv\config 目錄。

注意

組態歷程記錄檔不需要個別的存取控制清單, (ACL) 組態。 他們會從只有系統管理員擁有存取權的父目錄繼承其 ACL 值。

設定歷程記錄功能取決於 ApplicationHost 協助程式服務。 ApplicationHost 協助程式服務是與執行時間無關的服務,不需要 Windows Process Activation Service (WAS) 或 World Wide Web Publishing Service (WWW 服務) 運作。 它不相依于任何其他服務,而且其啟動類型為 Automatic

注意

如果 ApplicationHost 協助程式服務停止,設定歷程記錄功能將無法運作。

範例

下列程式碼範例會將歷程記錄子目錄的最大值設定為 20,並指定每隔 4 分鐘檢查ApplicationHost.config檔案是否有變更。 協助程式函式會顯示 ConfigurationHistorySection 變更前後的值。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the configuration history section.  
Set oSection = oWebAdmin.Get( _  
    "ConfigurationHistorySection.Path=" & _  
    "'MACHINE/WEBROOT/APPHOST',Location=''")  
  
' Display the class name of the section.  
WScript.Echo "[ " & oSection.Path_.Class & " ]" & vbCrLf  
  
' Display the initial settings.  
Call DisplaySettings("Initial Values", oSection)  
  
' Set the maximum number of history subdirectories to 20.  
oSection.MaxHistories = 20  
  
' Check ApplicationHost.config for changes every 4 minutes.  
oSection.Period = "00000000000400.000000:000"  
  
' Save the values to configuration.  
oSection.Put_  
  
' Refresh the oSection object variable with the new values.  
oSection.Refresh_  
  
' Show the changed settings.  
Call DisplaySettings("New Values", oSection)  
  
' ==== DisplaySettings helper function. ====  
Function DisplaySettings(HeadingText, oSection)  
  
    ' Display a heading.  
    WScript.Echo String(Len(HeadingText), "-")  
    WScript.Echo HeadingText  
    WScript.Echo String(Len(HeadingText), "-")  
  
    ' Display configuration history section properties.  
    WScript.Echo "Path: " & oSection.Path  
    WScript.Echo "Location: " & oSection.Location  
    WScript.Echo "History Path: " & oSection.HistoryPath  
    WScript.Echo "Period: " & oSection.Period  
    WScript.Echo "MaxHistories: " & oSection.MaxHistories  
    WScript.Echo  
End Function  
  

繼承階層架構

ConfigurationSection

ConfigurationHistorySection

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 檔案 WebAdministration.mof

另請參閱

ConfigurationSection 類別