batch-fileservicespooler

Batch file restart spooler and auto confirm a separate service


I'm trying to write a batch file for restarting the print spooler at our library. I thought I could get away with,

@echo off
NET stop spooler
NET start spooler

However, it then asks Y/N if I want to restart the "LPT:One Print Service" (lptclient) and I need it to auto confirm yes.

How would I go about setting that up?

Thanks!


Solution

  • There is a undocumented parameter that works with net commands, /y or /yes which bypasses the prompt. So in your case it would be: NET stop spooler /y

    Big thanks to imtheman for pointing this out on superuser; here.