Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete printer drivers with Vbscript

201 views
Skip to first unread message

BartV

unread,
Dec 23, 2002, 11:49:27 AM12/23/02
to
Hi,

I would like to create a script to delete all printers and all printer
drivers when logging off.

I found a bunch of articles describing how to add a printer, even found
artikels to delete a printer. But no examples of how to delete a printer
driver from within Vbscript.

I tried the "prnadmin.dll" but this only works on windows 2000, when I try
to delete a driver on XP I get an error stating "incorrect environment".

I also saw references to "DeletePrinterDriver" but that was an api and it
seems I cannot call api from within Vbscript.

Any ideas how to delete these drivers?

Thank you.

Bart.


David Candy

unread,
Dec 23, 2002, 11:53:44 AM12/23/02
to
Removes a shared network printer connection from your computer system.

object.RemovePrinterConnection(strName, [bForce], [bUpdateProfile])
Arguments
object
WshNetwork object.
strName
String value indicating the name that identifies the printer. It can be a UNC name (in the form \\xxx\yyy) or a local name (such as LPT1).
bForce
Optional. Boolean value indicating whether to force the removal of the mapped printer. If set to true (the default is false), the printer connection is removed whether or not a user is connected.
bUpdateProfile
Optional. Boolean value. If set to true (the default is false), the change is saved in the user's profile.
Remarks
The RemovePrinterConnection method removes both Windows and MS-DOS based printer connections. If the printer was connected using the method AddPrinterConnection, strName must be the printer's local name. If the printer was connected using the AddWindowsPrinterConnection method or was added manually (using the Add Printer wizard), then strName must be the printer's UNC name.

Example
The following code disconnects a network printer.

[VBScript]
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
WshNetwork.RemovePrinterConnection PrinterPath, true, true
[JScript]
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\PRN-CORP1\\B41-4523-A";
WshNetwork.RemovePrinterConnection(PrinterPath, true, true);
See Also
WshNetwork Object | AddPrinterConnection Method | AddWindowsPrinterConnection Method | EnumPrinterConnections Method | SetDefaultPrinter Method

--------------------------------------------------------------------------------

© 2001 Microsoft Corporation. All rights reserved.

Build: Topic Version 5.6.9309.1546


--
Aust Racist Govt http://www.smh.com.au/articles/2002/12/13/1039656210773.html
---------------------------------------------------------------
David Candy (Please note mail sent to dav...@sia.net.au will be bounced after 24-12-02 - Use da...@mvps.org after 25-12-02)
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"BartV" <bb...@ddddd.com> wrote in message news:au7er7$joq$1...@reader11.wxs.nl...

0 new messages