本文整理汇总了C#中System.Management.ManagementClass.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementClass.Delete方法的具体用法?C# ManagementClass.Delete怎么用?C# ManagementClass.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementClass
的用法示例。
在下文中一共展示了ManagementClass.Delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Uninstall
public override void Uninstall(IDictionary savedState)
{
try
{
ManagementClass MC = new ManagementClass(@"root\cimv2:Win32_Evil");
MC.Delete();
}
catch { }
try
{
base.Uninstall(savedState);
}
catch { }
}
示例2: Uninstall
public override void Uninstall(IDictionary savedState)
{
try
{
new System.EnterpriseServices.Internal.Publish().GacRemove("WMIKatz.dll");
ManagementClass MC = new ManagementClass(@"root\cimv2:Win32_WMIKatz");
MC.Delete();
}
catch { }
try
{
base.Uninstall(savedState);
}
catch { }
}
示例3: RegisterNonAssemblySpecificSchema
public void RegisterNonAssemblySpecificSchema(InstallContext installContext)
{
SecurityHelper.UnmanagedCode.Demand();
WmiNetUtilsHelper.VerifyClientKey_f();
SchemaNaming.InstallLogWrapper installLogWrapper = new SchemaNaming.InstallLogWrapper(installContext);
SchemaNaming.EnsureNamespace(installLogWrapper, this.GlobalRegistrationNamespace);
SchemaNaming.EnsureClassExists(installLogWrapper, this.GlobalInstrumentationClassPath, new SchemaNaming.ClassMaker(this.MakeGlobalInstrumentationClass));
SchemaNaming.EnsureClassExists(installLogWrapper, this.GlobalRegistrationClassPath, new SchemaNaming.ClassMaker(this.MakeNamespaceRegistrationClass));
SchemaNaming.EnsureClassExists(installLogWrapper, this.GlobalNamingClassPath, new SchemaNaming.ClassMaker(this.MakeNamingClass));
SchemaNaming.EnsureNamespace(installLogWrapper, this.NamespaceName);
SchemaNaming.EnsureClassExists(installLogWrapper, this.InstrumentationClassPath, new SchemaNaming.ClassMaker(this.MakeInstrumentationClass));
SchemaNaming.EnsureClassExists(installLogWrapper, this.RegistrationClassPath, new SchemaNaming.ClassMaker(this.MakeRegistrationClass));
try
{
ManagementClass managementClass = new ManagementClass(this.DecoupledProviderClassPath);
if (managementClass["HostingModel"].ToString() != "Decoupled:Com")
{
managementClass.Delete();
}
}
catch (ManagementException managementException1)
{
ManagementException managementException = managementException1;
if (managementException.ErrorCode != ManagementStatus.NotFound)
{
throw managementException;
}
}
SchemaNaming.EnsureClassExists(installLogWrapper, this.DecoupledProviderClassPath, new SchemaNaming.ClassMaker(this.MakeDecoupledProviderClass));
SchemaNaming.EnsureClassExists(installLogWrapper, this.ProviderClassPath, new SchemaNaming.ClassMaker(this.MakeProviderClass));
if (!SchemaNaming.DoesInstanceExist(this.GlobalRegistrationPath))
{
this.RegisterNamespaceAsInstrumented();
}
}
示例4: RegisterNonAssemblySpecificSchema
public void RegisterNonAssemblySpecificSchema(InstallContext installContext)
{
SecurityHelper.UnmanagedCode.Demand(); // Bug#112640 - Close off any potential use from anything but fully trusted code
// Make sure the 'Client' key has the correct permissions
WmiNetUtilsHelper.VerifyClientKey_f();
InstallLogWrapper context = new InstallLogWrapper(installContext);
EnsureNamespace(context, GlobalRegistrationNamespace);
EnsureClassExists(context, GlobalInstrumentationClassPath, new ClassMaker(MakeGlobalInstrumentationClass));
EnsureClassExists(context, GlobalRegistrationClassPath, new ClassMaker(MakeNamespaceRegistrationClass));
EnsureClassExists(context, GlobalNamingClassPath, new ClassMaker(MakeNamingClass));
EnsureNamespace(context, NamespaceName);
EnsureClassExists(context, InstrumentationClassPath, new ClassMaker(MakeInstrumentationClass));
EnsureClassExists(context, RegistrationClassPath, new ClassMaker(MakeRegistrationClass));
// Make sure Hosting model is set correctly by default. If not, we blow away the class definition
try
{
ManagementClass cls = new ManagementClass(DecoupledProviderClassPath);
if(cls["HostingModel"].ToString() != "Decoupled:Com")
{
cls.Delete();
}
}
catch(ManagementException e)
{
if(e.ErrorCode != ManagementStatus.NotFound)
throw e;
}
EnsureClassExists(context, DecoupledProviderClassPath, new ClassMaker(MakeDecoupledProviderClass));
EnsureClassExists(context, ProviderClassPath, new ClassMaker(MakeProviderClass));
if(!DoesInstanceExist(GlobalRegistrationPath))
RegisterNamespaceAsInstrumented();
}