Windows 10 I have a problem about remove printer via C# or Command-Line

KwangYong Lee

Member
Joined
Dec 3, 2016
Messages
2
Sorry for my bad English.

Hi. I have a problem about remove USB printer via C#, Command-Line or PowerShell.

I try to use C# APIs(with dll), Command-Line(printui, Devcon) and PowerShell(remove-printer, remove-printerdriver, remove-printerport). But It doesn't work only when the printer is disconnected or power off.

When the printer connected via USB and power on, It will be remove clearly. But conversely, It remains inactive(Translucent mode) and "Driver is unavailable".

I must to remove the printer as C# APIs or Command-Line, not to delete it right away(such as Device Manager, Devices and Printers of Control Panel)

I want to know how to remove the USB printer when the printer is disconnected or power off as C# APIs or Command-Line. Please help me.

p.s. I try to delete keys on Registry Editor. But some keys are require SYSTEM privilege. So, I can't delete it.
p.s 2. All the methods is worked on Windows 7. But It doesn't worked on Windows 8.1 and Windows 10.
p.s 3. I try to refresh window of Devices and Printers or reboot my computer, But it still remains inactive.
p.s. 4. When I double-Click my USB printer icon after remove it via C# APIs or Command-Line, my computer shows "0x00000709" error.

Help me......
 


Solution
Why are you removing the printer using powershell commands in the first place? Why don't you use device manager or Control Panel->Printers and Devices to remove the printer driver from the computer? Like most other folks use. Many of the popular printer companies such as HP, Lexmark, Canon, and Epson lock down the Registry when they run their uninstall scripts, and it might take you years to figure out how they do it. What's the purpose in reinventing the wheel here?

In most cases, if the printer cannot be removed using the above method, you can try to access SAFE MODE to uninstall the printer. That only works sometimes, as the libraries that the printer guys use in their uninstall scripts require Standard Mode...
Error 709 is "The printer name is invalid" did you restart the spooler service after?
 


Error 709 is "The printer name is invalid" did you restart the spooler service after?

Hello. Thank you for your reply!

Yes. I did restart the spooler service after that. But my USB printer doesn't disappear in list of Devices and Printers.
 


Why are you removing the printer using powershell commands in the first place? Why don't you use device manager or Control Panel->Printers and Devices to remove the printer driver from the computer? Like most other folks use. Many of the popular printer companies such as HP, Lexmark, Canon, and Epson lock down the Registry when they run their uninstall scripts, and it might take you years to figure out how they do it. What's the purpose in reinventing the wheel here?

In most cases, if the printer cannot be removed using the above method, you can try to access SAFE MODE to uninstall the printer. That only works sometimes, as the libraries that the printer guys use in their uninstall scripts require Standard Mode windows to be running in order to operate. Certainly worth trying though. I've fixed some very stubborn computers this way.

If none of these work, you most likely have a failing or severely corrupted W10 system and you'll need to repair that or completely reinstall it. In order to do that, you should first backup all your personal data to external media, and then perform hardware testing to make sure your RAM and Hard Drive are not at fault. Use my Troubleshooting Guide to go through these steps here: Windows 10 - Unclickable Task Bar

It appears that you've left out quite a bit of information on this post and it's leaving at least me very confused.:scratch: This means you probably tried a bunch of other methods to remove your printer and they all failed, and now you're trying to use a method which requires advanced computer skills which is not necessary unless you are running a computer repair business. If your printer doesn't come out with the methods above, you have serious window corruption and/or hardware failure. You need to better assess where the problem is coming from and be more forthcoming about why you are trying to fix it the way you are.

<<<BIGBEARJEDI>>>
 


Solution
Back
Top