Solved

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

Posted on 2007-12-06
6
284 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SD - WAN 2 45
Winsat Formal on a Windows 2012 R2 VM, with underlying Hyper-V Storage SSD? 7 15
Windows IPv6 DHCP server 8 37
Zebra Printer Selection 2 13
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

15 Experts available now in Live!

Get 1:1 Help Now