/// <summary> /// Deletes tracked WMI object instance /// </summary> /// <param name="wmiClass">instance to be deleted</param> public void Delete(object wmiClass) { if (!_instances.ContainsKey(wmiClass)) { throw new WmiObjectNotRegisteredException(); } _connection.DeleteInstance( _instances[wmiClass]); _instances.Remove(wmiClass); }
public static void DeleteInstanceSync(CimSession cimSession, string cimNamespace, string cimClassName) { try { CimInstance deleteInstance = DeleteInstanceCore(cimSession, cimNamespace, cimClassName); if (deleteInstance == null) { Console.WriteLine("DeleteInstance operation not performed"); return; } cimSession.DeleteInstance(cimNamespace, deleteInstance); Console.WriteLine("Instance Deleted Successfully"); } catch (CimException ex) { PrintCimException(ex); } catch (Exception ex) { Console.WriteLine(ex.Message); } }