Batch file to clear print queues on a remote SBS 2003 server

I'm looking for a way to allow workstation users to clear the print queues on a remote SBS 2003 server.

The users are admins of their local workstations, but NOT admins for the server.

This batch file seems to work at stopping & starting the print service on the server:

sc \\sbserver stop spooler
ping -n 5 www.google.com
sc \\sbserver start spooler


... but I cannot seem to find the right command to place in the middle to delete all the files in the PRINTERS folder.

I have tried:

del \\sbserver\%systemroot%\system32\spool\printers\*.*

... but I get "The network name cannot be found".

Any help is appreciated!
cricketmanAsked:
Who is Participating?
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Your Del command won't work as you already know - %systemroot% typically expands to c:\Windows - so saying
del \\sbserver\%systemroot%\system32\spool\printers\*.*
actually means
del \\sbserver\c:\windows\system32\spool\printers\*.*
And you can't use a colon in a UNC path.

*IF* the account running the batch file has permissions to the folder, use:
del "\\sbserver\c$\windows\system32\spool\printers\*.*"
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
You could create a scheduled task on a machine and save an administrator account and password to it and then let a non-administrator kick off the task.  I would also recommend NOT pinging google - instead ping the loopback address - 127.0.0.1
0
 
cricketmanAuthor Commented:
Did just what I wanted - thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.