Solved

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

Posted on 2007-12-06
6
281 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now