_Bat_ Posted September 4, 2007 Posted September 4, 2007 I have tried to use the following script to delete our old printer from our client machines: start \\SERVER\ICT_HP4050N rundll32 printui.dll,PrintUIEntry /gd /n\\SERVER\ICT_HP4050N N When I run it though, it comes up with the following error: Unable to delete the per machine printer connection. Operation could not be completed Does anyone know why this is happening? Google doesn't give me any info. The printer was added using a similar script, so it should work. Cheers!
lovelldr Posted September 4, 2007 Posted September 4, 2007 I dunno why that doesn't work, but I use the following within a vbs to it (assuming you added the printer with the network name, which in your case it looks like it did (\\SERVER): Option Explicit On Error Resume Next Dim objNetwork Dim objPrinters, ix Set objNetwork = CreateObject("WScript.Network") Set objPrinters = objNetwork.EnumPrinterConnections ' ### Delete all currently installed network printers For ix= 0 to objPrinters.Count - 1 Step 2 Dim sPrinter, sUNCPath sPrinter = objPrinters.Item(ix) sUNCPath = objPrinters.Item(ix+1) If InStr(1, sPrinter, "NAME_OF_SERVER", 1) > 0 Then objNetwork.RemovePrinterConnection sPrinter, True, True ElseIf InStr(1, sUNCPath, "NAME_OF_SERVER", 1) > 0 Then objNetwork.RemovePrinterConnection sUNCPath, True, True End If If Err <> 0 Then Wscript.Echo "Error deleting printer: " & Err.Description Err.Clear End If Next 1
_Bat_ Posted September 4, 2007 Author Posted September 4, 2007 That deletes all the network printers? I can only delete the one. We have more then one installed on each machine.
lovelldr Posted September 4, 2007 Posted September 4, 2007 OK, something like this should do it then: Option Explicit Dim objNetwork, objPrinters Set objNetwork = CreateObject("WScript.Network") Set objPrinters = objNetwork.EnumPrinterConnections ' ### Delete selected network printer Dim sPrinterName sPrinterName = "\\SERVER\ICT_HP4050N" objNetwork.RemovePrinterConnection sPrinterName, True, True
vote-for-pedro Posted February 25, 2009 Posted February 25, 2009 Hi, is it possible to remove a printer that has been added using START \\CHSDC\CR1-COLOUR within a batch file that runs at start up.
timzim Posted February 25, 2009 Posted February 25, 2009 If you use KiXtart you could use DelPrinterConnection("\\SERVER\ICT_HP4050N")
vote-for-pedro Posted February 25, 2009 Posted February 25, 2009 thanks timzim i've also found reg delete "hkcu\printers\connections" /f works nicely in a batch file
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now