Computing.Net > Forums > Windows XP > remove printer connection

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

remove printer connection

Reply to Message Icon

Name: mla_ca520
Date: September 1, 2009 at 13:58:38 Pacific
OS: Windows XP
Subcategory: Configurations
Tags: VB 2008, Remove Printer
Comment:

I have been tasked with converting our vbscripts to vb executables. One script uses WSH to delete network printers and I can't figure out how to accomplish the same task using VB...here is the vbs/wsh

Set objNetwork = CreateObject("Wscript.Network")
objNetwork.RemovePrinterConnection objPrinter.Name



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: September 1, 2009 at 14:18:36 Pacific
Reply:

If you are converting to VB I would get rid of WSH altogether. It is far to slow and cumbersome to use withing VB. Most things done with WSH can be achieved via the API which is faster and more eficient.

Try some of these:

http://www.google.co.uk/search?hl=e...

Stuart


0

Response Number 2
Name: mla_ca520
Date: September 10, 2009 at 10:53:37 Pacific
Reply:

Answered:

Private Sub btnRemovePrinters_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeletePrinter.Click
Dim PrtrToDel = Me.lstPrtrToDelete.Items
Dim Prtr As ListViewItem
For Each Prtr In PrtrToDel
If Prtr.Selected = True Then
Call DeletePrinterConnection(Prtr.Text)
End If
Next
ListLocalPrinters()
End Sub


Private Sub ListLocalPrinters()
Try
Dim searcher As New ManagementObjectSearcher("root\CIMV2", _
"SELECT * FROM Win32_Printer  Where Local = FALSE")
lstPrtrToDelete.Items.Clear()
For Each queryObj As ManagementObject In searcher.Get()
lstPrtrToDelete.Items.Add(queryObj("DeviceID"))
Next
lstPrtrToDelete.View = View.List
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Sub


1

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Blurp sound Yahoo mail problem



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: remove printer connection

printer connection www.computing.net/answers/windows-xp/printer-connection/141137.html

Remove printer (brohter hl-270) www.computing.net/answers/windows-xp/remove-printer-brohter-hl270/154510.html

Printer connection problem www.computing.net/answers/windows-xp/printer-connection-problem/101088.html