本文整理汇总了C#中System.Management.ManagementObject.Put方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementObject.Put方法的具体用法?C# ManagementObject.Put怎么用?C# ManagementObject.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementObject
的用法示例。
在下文中一共展示了ManagementObject.Put方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplySettings
/// <summary>
/// Apply settings to a Management object.
/// </summary>
/// <param name="target">The ManagamentObject to apply the settings to</param>
/// <param name="properties">A Dictionary object containing the properties and their value.</param>
/// <remarks>
/// The properties Dictionary contains the name of the property as the key, and the value of the property as the value.
/// </remarks>
protected void ApplySettings(ManagementObject target, Dictionary<string, object> properties)
{
foreach (var kv in properties)
{
target.Properties[kv.Key].Value = kv.Value;
}
target.Put();
}
示例2: ManagementObjectCopy
/// <summary>
/// Copy a ManagementObject to a new Path
/// </summary>
/// <param name="MO"></param>
/// <param name="Scope"></param>
/// <param name="Dest"></param>
static public void ManagementObjectCopy(ManagementBaseObject MO, ManagementScope Scope, ManagementPath Dest)
{
if (MO != null)
{
try
{
ManagementObject MORemote = new ManagementObject();
ManagementClass RemoteClas = new ManagementClass(Scope, Dest, new ObjectGetOptions());
MORemote = RemoteClas.CreateInstance();
foreach (PropertyData PD in MO.Properties)
{
try
{
MORemote.Properties[PD.Name].Value = PD.Value;
}
catch { }
}
MORemote.Put();
}
catch { }
}
}
示例3: SetNTLMAuth
void SetNTLMAuth(ManagementScope scope, string path)
{
var site = new ManagementObject(scope, new ManagementPath(path), null);
site["AuthNTLM"] = true;
site.Put();
}
示例4: SetAuth
void SetAuth(ManagementScope scope, string path, string authSetting, bool setting)
{
var site = new ManagementObject(scope, new ManagementPath(path), null);
site[authSetting] = setting;
site.Put();
}
示例5: SetAppPool
private void SetAppPool(ManagementScope scope, string path, string appPoolId)
{
var site = new ManagementObject(scope, new ManagementPath(path), null);
site["AppPoolId"] = appPoolId;
site.Put();
}
示例6: AddScriptMapToSite
private void AddScriptMapToSite(ManagementScope scope, string siteId, ScriptMap scriptMap)
{
var site = new ManagementObject(scope, new ManagementPath(String.Format(@"IIsWebVirtualDirSetting.Name=""W3SVC/{0}/root""", siteId)), null);
var scriptMaps = (ManagementBaseObject[]) site["ScriptMaps"];
var newScriptMaps = new ManagementBaseObject[scriptMaps.Length + 1];
scriptMaps.CopyTo(newScriptMaps, 0);
ManagementObject newScriptMap = new ManagementClass(scope, new ManagementPath("ScriptMap"), null).CreateInstance();
newScriptMap["Extensions"] = scriptMap.Extension;
newScriptMap["Flags"] = scriptMap.Flags;
newScriptMap["IncludedVerbs"] = scriptMap.IncludedVerbs;
newScriptMap["ScriptProcessor"] = scriptMap.Executable;
newScriptMaps[newScriptMaps.Length - 1] = newScriptMap;
site["ScriptMaps"] = newScriptMaps;
site.Put();
}
示例7: oImpSCCMPol
/// <summary>
/// Merges the XML data into local policy
/// </summary>
/// <param name="xDoc"></param>
/// <param name="bPersistent"></param>
/// <returns></returns>
internal ManagementObject oImpSCCMPol(XmlDocument xDoc, bool bPersistent)
{
string sPolicyID = xDoc.DocumentElement.Attributes["PolicyID"].Value;
ManagementObject MO = new ManagementObject();
ManagementObject MORet = new ManagementObject();
XmlNodeList xActions = xDoc.GetElementsByTagName("PolicyAction");
foreach (XmlNode xNode in xActions)
{
if (string.Compare(xNode.Attributes["PolicyActionType"].Value, "WMI-XML", true) == 0)
{
string sRuleId = xNode.ParentNode.Attributes["PolicyRuleID"].Value;
XmlNodeList xClasses = xNode.ChildNodes;
foreach (XmlNode xClass in xClasses)
{
/*ManagementObject MOPol = ImportSCCMPolicy(xClass, @"root\ccm\Policy", false);
MOPol.SetPropertyValue("PolicyID", sPolicyID);
MOPol.SetPropertyValue("PolicyRuleID", sRuleId);
MOPol.Put(); */
//Load Policy in RequestedConfig
ManagementObject MOReq = iImportSCCMPolicy(xClass, @"root\ccm\Policy\Machine\RequestedConfig", bPersistent);
MOReq.SetPropertyValue("PolicyID", sPolicyID);
MOReq.SetPropertyValue("PolicyRuleID", sRuleId);
MOReq.Put();
//Load Policy in ActualConfig
MO = iImportSCCMPolicy(xClass, @"root\ccm\Policy\Machine\ActualConfig", false);
MO.Put();
if (string.Compare(MO.SystemProperties["__Class"].Value.ToString(), "CCM_SoftwareDistribution", true) == 0)
{
MO.Get();
MORet = MO;
}
}
}
}
return MORet;
}