Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何删除一个";“僵尸”;c#中的网络打印机连接?_C#_Printing_Wmi_Access Denied_Network Printers - Fatal编程技术网

如何删除一个";“僵尸”;c#中的网络打印机连接?

如何删除一个";“僵尸”;c#中的网络打印机连接?,c#,printing,wmi,access-denied,network-printers,C#,Printing,Wmi,Access Denied,Network Printers,我正在尝试删除从printserver中删除的网络打印机 我正在使用此代码删除已安装的打印机: public void unmapPrinter() { ConnectionOptions options = new ConnectionOptions(); options.EnablePrivileges = true; ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath,

我正在尝试删除从printserver中删除的网络打印机

我正在使用此代码删除已安装的打印机:

    public void unmapPrinter()
{
    ConnectionOptions options = new ConnectionOptions();
    options.EnablePrivileges = true;
    ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath, options);
    scope.Connect();
    ManagementClass win32Printer = new ManagementClass("Win32_Printer");
    ManagementObjectCollection printers = win32Printer.GetInstances();
    foreach (ManagementObject printer in printers)
    {
        printer.Delete();
    }
}
这适用于普通打印机,但有一个打印机已从printerserver中删除,并返回“拒绝访问”。有人知道这个问题吗


即使windows也可以取消对该打印机的监控,当我尝试从“打印机和硬件”中删除该打印机时,它会告诉我该打印机处于警告状态。

作为管理员运行如何它已经作为管理员运行了如何作为管理员运行它已经作为管理员运行了