0

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!

Cori G
  • 5
  • 1
  • 3

1 Answers1

0

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.

John Kens
  • 1,615
  • 2
  • 10
  • 28
  • 1
    That worked pretty well. The only downside is that it doesn't restart the LPT service. I was able to remedy that by tossing "NET start lptclient" at the end. And apparently it only works when run as administrator. So I made a shortcut, set the shortcut to "Run as administrator," and tossed it in the startup folder. Many thanks! – Cori G Aug 05 '18 at 19:36
  • @CoriG Many windows services require administrative permissions when dealing with the `NET stop` and the `NET start` command. Glad your issue was resolved. – John Kens Aug 05 '18 at 19:47