Couldn't be able to remove Bluetooth printer programatically in windows 8.1 RRS feed

  • Question

  • I am working on a client requirement where I need to delete the existing printer at the end of the day.I used WMI to delete printer.

    ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath);            scope.Options.EnablePrivileges = true;            scope.Options.Authentication = AuthenticationLevel.Default;                        scope.Connect();            SelectQuery query = new SelectQuery("SELECT * FROM Win32_Printer");            ManagementObjectSearcher search = new ManagementObjectSearcher(scope, query);            ManagementObjectCollection printers = search.Get();            foreach (ManagementObject printer in printers)            {                string prnName = printer["Name"].ToString().ToLower();                if (prnName.Contains("abc"))                {                    printer.InvokeMethod("Delete", null, null);                    //printer.Delete();                    Console.WriteLine(prnName + "is uninstalled");                    Console.ReadLine();                    printer.Dispose();                                    }            }

    Once after the execution of the above program, The printer icon in the control panel is greyed out but not deleted.The same printer is coming back after restarting the machine.

    Even I tried with DOS command: 

    printui /dl /n "printername"

    I Observed in both scenarios the printer is actually deleted from the device manger but not from the control whenever I restart the machine the printer is coming back to live.

    Could some please assist me in resolving this Issue. This is a Bluetooth printer installed through device pairing.

    Thursday, September 10, 2015 7:14 AM