Hi All, I'm trying to restart the print spooler with a batch file, and automatically answer the prompt to stop the tcp/ip service with a Y or yes. I have this: @echo off rem stop spooler net stop spooler rem delete print jobs rem start spooler net start spooler net start lpdsvc echo done! What am I missing?
its been a while but I think you need to to add /Y or something to the net stop command... http://support.microsoft.com/kb/89356
The print spooler won't stop unless the TCP/IP service is stopped too, because the TCP/IP print server is dependent on the spooler.
DUH! I stopped the TCPIP service FIRST then stopped the spooler and it didn't prompt. It now works perfectly. Thanks all!
Thanks Atomic. Mine looked very similar but I've changed it to look like yours. Works like a charm! The main reason I'm doing this is because the printer drivers on our print server seem to have memory leaks, and I see the spooler memory size go up to 1.5GB throughout the day, which eventually causes problems printing. Restarting the spooler service always works, so I just wanted to automate it with a batch file and task scheduler.
Ouch that's a badly written driver. If it's running as a scheduled task you can remove the echo lines as you won't see the console output: Code: net stop lpdsvc net stop spooler net start spooler net start lpdsvc And if you want to clear jobs from the spooler also: Code: net stop lpdsvc net stop spooler ping localhost -n 4 > nul del /q %SystemRoot%\system32\spool\printers\*.* net start spooler net start lpdsvc The 'ping' line just adds a delay before clearing the spooler, you don't really need it but it helps to be sure all file locks are clear.
you can just put a /y after a net stop to automatically answer yes to it stopping other services. net stop spooler /y stops spooler AND fax service (if you use fax, relies on the print spooler)
Ah thanks Margo. I was putting the /y before the net stop command. I think I'll use the delete print queue command. It saves me having to clear it manually.