Batch file restart spooler and auto confirm a separate service

9.1k Views Asked by At

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!

1

There are 1 best solutions below

2
On BEST ANSWER

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.