Solved

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

Posted on 2007-12-06
6
288 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Public Printing Options 3 49
Problem to line 23 54
RDP redirected printers not working on mac 4 23
EXCEL 2010 wants to print 1 page PER CELL...!! crazy 6 28
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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…

829 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