Solved

Need someone to review a script (to delete all network printers) error - pointer to another question

Posted on 2007-12-06
6
289 Views
Last Modified: 2010-05-18
I am not a script guru, I can get by for my purposes, but don't know scripts inside and out.  I posted an answer to the below question:
http://www.experts-exchange.com/Hardware/Peripherals/Printers_Scanners/Q_23003197.html?cid=238#a20418341

The poster is getting an error when running the script.  I don't know what is causing it, so am looking for someone who can review it the question and give the poster some more suggestions.

Thanks,

michko
0
Comment
Question by:michko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:Kurt_Braeckmans
ID: 20419780
I think that this can help you
ON ERROR RESUME NEXT
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 step 2
 If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
  WSHNetwork.RemovePrinterConnection WSHPrinters.Item
  (LOOP_COUNTER +1),True,True
 End If
next
wscript.quit

Open in new window

0
 
LVL 12

Expert Comment

by:Kurt_Braeckmans
ID: 20419819
michko,

I've made an error in the script.
attempt 2:
ON ERROR RESUME NEXT
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 step 2
 If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
  WSHNetwork.RemovePrinterConnection 
  WSHPrinters.Item(LOOP_COUNTER +1),True,True
 End If
next
wscript.quit

Open in new window

0
 
LVL 27

Author Comment

by:michko
ID: 20419938
Thanks.  Once solved for poster, I'll credit points here also.  Poster only put 50 pts for their question, so it won't violate the 500 max limit.  Appreciate the help.
0
Surfing Is Meant To Be Done Outdoors

Featuring its rugged IP67 compliant exterior and delivering broad, fast, and reliable Wi-Fi coverage, the AP322 is the ideal solution for the outdoors. Manage this AP with either a Firebox as a gateway controller, or with the Wi-Fi Cloud for an expanded set of management features

 
LVL 7

Accepted Solution

by:
avatar-e earned 200 total points
ID: 20420130
You tried my last code?
0
 
LVL 12

Assisted Solution

by:Kurt_Braeckmans
Kurt_Braeckmans earned 50 total points
ID: 20420217
credit goes to avatar-e.

Kurt
0
 
LVL 27

Author Closing Comment

by:michko
ID: 31413131
My thanks to both of you for your help.  
0

Featured Post

Now Available: Firebox Cloud for AWS and FireboxV

Firebox Cloud brings the protection of WatchGuard’s leading Firebox UTM appliances to public cloud environments. It enables organizations to extend their security perimeter to protect business-critical assets in Amazon Web Services (AWS).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question