i built a vbs script to remove installed xerox and hp printer drivers and it's been working for us. copy\paste to a plain txt file and rename xxx.vbs, run as administrator with all other users logged off. it does work when run locally or across a network.
note: the section "'Delete Folder and files 'Delete HP Xerox files" and "'check if HP or Xerox" is where the driver files are selected if you need to modify this to delete other printer devices.
<from below>
on error resume Next 'strID =Inputbox("Enter IP or TAG: ","data Requested",".") 'strComputer = strID strComputer = "." 'Detecting 32bit or 64bit Dim WshShell Dim OsType Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("WScript.Shell") OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") If OsType = "x86" then Wscript.Echo "Windows 32bit system detected" strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\" Set folder = fso.GetFolder("C:\Windows\System32\spool\drivers\W32X86\3") elseif OsType = "AMD64" then Wscript.Echo "Windows 64bit system detected" strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\" Set folder = fso.GetFolder("C:\Windows\System32\spool\drivers\x64\3") end If 'loop through printers list in registry Const HKEY_LOCAL_MACHINE = &H80000002 Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_ strComputer & "\root\default:StdRegProv") 'find driver subkeys 'strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\" objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys 'WScript.Echo "Subkeys under " & "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3" For Each subkey In arrSubKeys check Next 'stop spooler service Wscript.Echo "stopping spooler service" Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colService = objWMIService.ExecQuery( "Select * from Win32_Service Where Name = 'Spooler'") For Each svc In colService svc.StopService Next 'Delete Folder and files 'Delete HP Xerox files for each f in folder.Files On Error Resume Next name = f.Name If (InStr(name,"h")) = 1 Or (InStr(name,"x")) = 1 Then delete Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFolder("C:\Windows\System32\spool\drivers\x64\3\en-US") objFSO.DeleteFolder("C:\Windows\System32\spool\drivers\x64\3\Xerox") objFSO.DeleteFolder("C:\Windows\System32\spool\drivers\W32X86\3\en-US") objFSO.DeleteFolder("C:\Windows\System32\spool\drivers\W32X86\3\Xerox") Next 'start service Wscript.Echo "starting spooler service" Set colService = objWMIService.ExecQuery( "Select * from Win32_Service Where Name = 'Spooler'") For Each svc In colService svc.StartService Next 'alert on completion Wscript.Echo "Completed" 'Delete Folder and files 'Delete HP Xerox files Sub delete f.Delete True If Err Then Wscript.Echo "Error deleting:" & Name & " - " & Err.Description Else 'Wscript.Echo "Deleted:" & Name End If On Error GoTo 0 'Next End Sub 'check if HP or Xerox Sub check strSubkey = subkey If (InStr(subkey,"HP")) = 1 Or (InStr(subkey,"Xerox")) = 1 Then delDriver End Sub 'delete driver subkeys Sub delDriver delkey = strKeyPath & subkey Return = objReg.DeleteKey(HKEY_LOCAL_MACHINE, delkey) If (Return = 0) And (Err.Number = 0) Then Wscript.Echo subkey & " successfully deleted" Else Wscript.Echo "DeleteKey failed. Error = " & Err.Number End If End Sub
<from above>
This worked great, thanks.
here's a quick and dirty batch file to automate it the removal.
rem deletes printer (as listed in devices and printers)and drivers (-v "version", -e "windows environment"
cscript prnmngr.vbs -d -p "xerox printer name"
cscript prndrvr.vbs -d -m "xerox print driver name" -v "3" -e "Windows x64"
echo deleted driver "Xerox Workcentre 6400XF PCL6" -v "3" -e "Windows x64"
rem the below lines are not nescessary
rem opens devices and printers
%windir%\explorer.exe shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A}
rem opens print management
%systemroot%\system32\printmanagement.msc
I tried restarting the spooler, rebooting, disabling then rebooting, etc. That does not work. It still gives the "in use" message. After looking around on the net, I found a workaround, You have to remove the drivers a few seconds after restarting the spooler. If you wait any longer the drivers get locked down. (I usually have to try several times before I get it.) I manage 120 computers in a domain with 6 workcentre machines. It would be nice if there were a way to more easily remove these drivers.
restart ur computer and the spooler will be reset :)
when resetting the spooler manually:
in cmd prompt write "net stop spooler" and when thats done you need to start it up again so just write "net start spooler".
I have this same problem trying to remove the Global Print Driver on a Windows 7 machine. I have removed the printer from the local machine and have tried restarting the spooler. I still cannot remove it.
i think if you restart the print spooler, then you can delete it :)
Hello all,
I am presently trying to manually remove all the printer drivers from a Windows 7 Professional machine. There are two installed print driver packages that I just can't get removed no matter what I try. I've searched high and low for a solution, tried everything I can find but nothing works.
"Print Management" utility in Win7 tells me this when I try to remove a driver package;
Failed to remove driver Xerox Phaser 4620 PCL6. The specified printer driver is currently in use.
Failed to remove package x2wcorx.inf. Driver package is in use.
Does anyone know if Xerox has a utility available that will remove printer drivers from Win7?
cheers,
Mark
Solved! Go to Solution.