简体   繁体   中英

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM