{"id":627,"date":"2015-05-08T08:35:44","date_gmt":"2015-05-08T06:35:44","guid":{"rendered":"https:\/\/www.em-soft.si\/myblog\/elvis\/?p=627"},"modified":"2015-05-08T08:35:44","modified_gmt":"2015-05-08T06:35:44","slug":"delete-canon-print-drivers-with-powershell","status":"publish","type":"post","link":"https:\/\/em-soft.si\/myblog\/elvis\/?p=627","title":{"rendered":"Delete Canon print drivers with PowerShell"},"content":{"rendered":"<p><span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">Some days ago I had a problem with Canon drivers (and to be honest, I am convinced that Canon has to do something to solve the situation). At this moment the only way to change Canon printer driver it is to reinstall it from the original package and this cannot be done silently (as I know, correct me if I am wrong). Uninstalling drivers via standard way is not possible as the \u201cdriver is in use\u201d all the time, the spooler is active and if you stop the spooler, you cannot uninstall the driver because the spooler is not running. Crazy!<\/span><br \/>\n<span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">What was my idea? First, I have an environment with few thousand computers, so all the process must be silent, automated and if it is possible traceable. As I have printers mapped form print server, the printers have to remain mapped and the driver should be downloaded from the print server on the first use (of course you have to manually reinstall new driver on print server). The best way to do this kind of work is PowerShell.<\/span><br \/>\n<span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">OK, so for the first I had to create a log source for the script as I wanted to trace all the work of the script and I wrote few lines of code to define all settings needed to put my events in log. <\/span><br \/>\n<span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">After this, it is absolutely needed that Print spooler is running and driver is not in use. I found a solution stopping the print spooler, renaming the winprint key in registry (this key is responsible for print process used by Canon drivers) and starting the spooler. In this way I created the situation where the print spooler is running, but not the winprint process\u2013 so the Canon drivers are not in use and they can be uninstalled.<\/span><br \/>\n<span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">The rest of the script find all Canon drivers (from registry), remove them with rundll23 PrintUI.dll command, rename winprint registry key back and restart the print spooler once again.<\/span><br \/>\n<span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">The final part is to write success or failure to Application log. <\/span><\/p>\n<p><span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">When you run script be careful to two things:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">The script has to run as local administrator account or system account. If you run the script as user with less privileges, it will fail.<\/span><\/li>\n<li><span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">This script is valid for a 64 bit systems. If you have a 32 bit systems, you have to correct lines where registry keys are specified.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">The script can be downloaded here: <a href=\"https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2015\/05\/RemovePrnDrv.zip\">RemovePrnDrv Script<\/a>.<\/span><\/p>\n<p><span style=\"font-family: times new roman,times,serif; font-size: 12pt;\">Good work!<\/span><a style=\"text-decoration:none\" href=\"\/index.php?s=shop-apotheke-imusporin\">.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some days ago I had a problem with Canon drivers (and to be honest, I am convinced that Canon has to do something to solve the situation). At this moment the only way to change Canon printer driver it is to reinstall it from the original package and this cannot be done silently (as I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,15],"tags":[41,40],"class_list":["post-627","post","type-post","status-publish","format-standard","hentry","category-powershell","category-windows-server","tag-powershell","tag-windows-server"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts\/627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=627"}],"version-history":[{"count":1,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts\/627\/revisions"}],"predecessor-version":[{"id":629,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts\/627\/revisions\/629"}],"wp:attachment":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}