C:\_G\WWW\~ELISANET\INFO\tscmd129.html
<http://www.elisanet.fi/tsalmi/info/tscmd129.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Mon 5-Nov-2018 11:25:02

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



129} Is it possible to stop and reset the print spooler with a script?

  @echo off & setlocal enableextensions
  echo +----------------------------------------------------+
  echo ^| CLRSPOOL.CMD Stop and reset print spooler          ^|
  echo ^| By Prof. Timo Salmi, Last modified Sun 29-Jan-2006 ^|
  echo +----------------------------------------------------+
  ::
  if "%~1"=="?" goto _usage
  if "%~1"=="/?" goto _usage
  ::
  :: The path to the spooler files

  set spool_=C:\WINDOWS\system32\spool\PRINTERS
  ::
  :: Spool contents

  dir "%spool_%"
  echo.
  ::
  :: Ask for confirmation

  :_ask
  set ask_=
  set /p ask_="Reset the print spooler [Y/n]?"
  if /i "%ask_%"=="n" goto _out
  if /i not "%ask_%"=="y" if not "%ask_%"=="" goto _ask
  ::
  :: Clear the spooler
  :: If you get "System error 5 has occurred / Access is denied"
  :: then "Run as administrator"

  net stop spooler
  for %%f in ("%spool_%\*.*") do (
    if exist "%%f" del "%%f"
    )
  net start spooler
  dir "%spool_%"
  :: See FAQ item #2 for an explanation of the next line
  if not defined cmdbox if defined PauseIfFromDesktop pause
  goto _out
  ::
  :_usage
  echo.
  echo Usage: DELSPOOL
  echo.
  echo High enough user privileges are required to complete this task.
  echo Else the net stop/start commands will just produce error messages.
  goto _out
  ::
  :_out
  endlocal & goto :EOF

Also of interest:

  cscript "C:\WINDOWS\system32\prnqctl.vbs"

  cscript "C:\Windows\System32\Printing_Admin_Scripts\en-US\prnqctl.vbs"

References/Comments:
  How to clear the print spool
  Prnqctl.vbs 2 3
  Google Groups 14 Feb 2011 06:53:17

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd129.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd129
http://www.elisanet.fi/tsalmi/info/tscmd129.html
file:///c:/_g/www/~elisanet/info/tscmd129.html