Skip to content

Instantly share code, notes, and snippets.

@jeffory
Created May 22, 2012 10:32
Show Gist options
  • Save jeffory/2768207 to your computer and use it in GitHub Desktop.
Save jeffory/2768207 to your computer and use it in GitHub Desktop.
Printer Reset Batch
@echo off
goto skiphelp
:help
echo Printer Reset Script Usage
echo(by Keith McGahey ^<jeffory@c0d.in^>
echo/
echo( /? - display this help
echo( /f - force script to run, skipping confirmation question
goto end
:skiphelp
rem Check arguments for switches...
:Loop
if "%1"=="" GOTO Continue
if "%1"=="/f" (
goto skipconfirm
)
if "%1"=="/?" (
goto help
)
shift
goto Loop
:Continue
echo Restart printers/clear print queue? (y/n)
set /p confirm=
if "%confirm%"=="y" (
:skipconfirm
echo Stopping spooler...
net stop spooler
echo Deleting print jobs...
del "%systemroot%\system32\spool\printers\*.shd"
del "%systemroot%\system32\spool\printers\*.spl"
echo Starting spooler...
net start spooler
goto end
)
echo Canceled.
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment