Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all printers from command line/batch 1

Status
Not open for further replies.

meastaugh1

Technical User
Apr 21, 2002
316
Hi,

I need to delete all the print queues from a user's profile at logon with a logon script. I would have thought I could have done it with printui.dll, but it seems to need me to specify the queue name(?). It isn't possible to know what queues will exist, so I need to be able to use a * or something like that.
 
There are some native command line tools you can use.

prnnqctl.vbs Syntax

cscript prnqctl.vbs -x [-s RemoteComputer] -p PrinterName [-u UserName -w Password]

Parameters
-x
Required. Specifies that you want to cancel all jobs spooled to a printer.
-s RemoteComputer
Specifies, by name, the remote computer to which the printer for which you want to cancel all jobs is attached. If you do not specify a computer, the local computer is used.
-p PrinterName
Required. Specifies, by name, the printer for which you want to cancel all print jobs.
-u UserName -w Password
Specifies an account with permissions to connect by using Windows Management Instrumentation (WMI) services to the computer on which you want to cancel all print jobs. All members of the Administrators group for that computer have these permissions, but the permissions can also be granted to other users. If you do not specify an account, you must be logged on under an account with these permissions for the command to work. For more information about WMI, see Related Topics.
/?
Displays help at the command prompt.
Remarks
This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.
If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").
 
Thanks for your reply.

Will that command just cancel print jobs? Sorry if I didn't make clear in my original post, I need to delete the printers.

thanks
Mike
 
Is it your intention to delete the printers at every logon? There should be no reason to do so, but it is easily scripted: See the other scripting resources if this does not answer a specific need.

If I was asked to force a cleanup of existing printers, I would use cleanspl.exe, a Windows 20003 reskit utility that works under Win2k and XP clients perfectly. It does require at least on XP client to unpack the files needed. There are alternatives, see:
But I would as a personal choice use cleanspl.exe:
 
The need to delete printers is because most other clients computers in the domain have a 3rd party AD integrated tool which allows printers to be delivered to computers based on their OU. At logon all printers are deleted, then the relevant printers are added. I just need to replicate this behaviour in a script.

Those links look useful, thanks.
 
Honestly, there should be no reason to delete and rebuild the printer definitions at logon.

Cleansple.exe (discussed above) will do this for Win2k or XP clients without issue.

But quite frankly, I would be more concered as to why there is a requirment to do so.

This is not a normal requirement nor behavior for XP (or other clients) in a Win2k Domain.

I suspect there are deeper issues with the steup of this network that will end up breaking your heart.

Bill Castner

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top