Link to home
Start Free TrialLog in
Avatar of mijones
mijones

asked on

VBScript to delete printers.

Hi

I need a script to run in Windows 2000 every night to delete all the printers on a server, because we're having problems with Citrix.  Can I do this with Network.RemovePrinterConnection?  I need to be able to not have to list the name of every printer because there are 100s of them.  Is there anyway of using a wildcard to do this?

Many thanks.

Martin.
ASKER CERTIFIED SOLUTION
Avatar of aelatik
aelatik
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mijones
mijones

ASKER

Thanks guys.  I'll look in to it and do the points thing later.

Avatar of mijones

ASKER

Many thanks for your help.

The printer enumeration works great, but I'm still having problems in that it is coming up with errors saying that the network connection doesn't exist. With a source of WSHNetwork.RemoveNetworkDrive ?!  Might this be because I don't have an Active Directory installed? (Still on NT here)

Cheers

That is for drive mappings : WSHNetwork.RemoveNetworkDrive

That is not what we are discussing here? But put an " on error resume next" on top and it ill go fine.
The problem is that if the mapping isn't there anymore if will give you an error.
Check to see if you have WSH installed on the Server.
lyonst,

Without WSH he wouldn't be able to do the enumeration. So i think that is installed very well.
Avatar of mijones

ASKER

Thanks.  I know that WSHNetwork.RemoveNetworkDrive in for removing mapped drives, that's why I was confused!!  I've reinstalled WSH to check that out and the same error occured :(  I've tried in on other servers and workstations in the domain and the same response.  

I was wondering if the WSHNetwork.RemovePrinterConnection was a ADSI method and therefore wouldn't work on our NT domain?  Or is there something else i've missed (probably!)?  I'm going to try it on one of our Win2k ADs or Win2k3 ADs, to see if it works there.

Cheers


Avatar of mijones

ASKER

Hi again.

With the "on error resume next" it now works on my workstation to delete the printers :)  The only problem is that it has no effect on the server in question.  The problem is that the printers are virtual printer connections created by Citrix when user connects and therefore i'm not sure if they are set up in the same way as "normal" printers.  I think that I might have to remove the registry settings for them :(