The following code example specifies new values for the DataSource, Tablename, Username, and Password properties. A helper function displays the values before and after the change.
|
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject( _
"winmgmts:root\WebAdministration")
' Get the ODBCLoggingSection.
Set oSection = oWebAdmin.Get("OdbcLoggingSection.Path=" & _
"'MACHINE/WEBROOT/APPHOST',Location=''")
' Display the class name of the section.
WScript.Echo "[ " & oSection.Path_.Class & " ]"
' Display the initial values.
Call DisplayValues("Initial Values", oSection)
' Specify new ODBCLoggingSection property values.
oSection.DataSource = "ODBCLoggingDB"
oSection.TableName = "ODBCLoggingTable"
oSection.Username = "ODBCLoggingAdmin"
oSection.Password = "ODBCLoggingPassword"
' Save the values to configuration.
oSection.Put_
' Refresh the oSection object variable with the new values.
oSection.Refresh_
' Show the changed values.
Call DisplayValues("New Values", oSection)
' ==== DisplayValues helper function. ====
Function DisplayValues(HeadingText, oSection)
' Display a heading.
WScript.Echo
WScript.Echo HeadingText
WScript.Echo String(Len(HeadingText), "-")
' Display section properties.
WScript.Echo "Path: " & oSection.Path
WScript.Echo "Location: " & oSection.Location
WScript.Echo "DataSource: " & oSection.DataSource
WScript.Echo "TableName: " & oSection.TableName
WScript.Echo "Username: " & oSection.Username
WScript.Echo "Password: " & oSection.Password
End Function
|