• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

WSHNetwork.RemoveNetworkDrive error when deleting a printer

Basically I get a WSHNetwork.RemoveNetworkDrive error when removing a printer using a vbscript on one of our servers...works on others, just this one.
0
dcarrion
Asked:
dcarrion
  • 3
1 Solution
 
dcarrionAuthor Commented:
vbscripting up to date. almost identical to the one that works.
0
 
EDDYKTCommented:
remove the printer using RemoveNetworkDrive?

Should you use RemovePrinterConnection?

Option Explicit
Dim objNetwork, strUNCPrinter

strUNCPrinter = "\\Server\printer"
Set objNetwork = CreateObject("WScript.Network")
on error resume next
objNetwork.RemovePrinterConnection strUNCPrinter
Wscript.Quit

0
 
dcarrionAuthor Commented:
Yep that's what i'm doin :)
no go...
0
 
dcarrionAuthor Commented:
Okay Hold on

Only happens when I try to remove local printers that are attatched via terminal services...see script below.

Set oNetwork = WScript.CreateObject("WScript.Network")
Set oPrinter = oNetwork.EnumPrinterConnections
For iCount = 0 to oPrinter.Count - 1 Step 2

Result = InStr(oPrinter.Item(iCount+1), "Session")

If Result > 0 then

oNetwork.RemovePrinterConnection oPrinter.Item(iCount+1),True,False

Else


End if


Next
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now