Skip to content

Instantly share code, notes, and snippets.

@Yaromaxx
Last active October 31, 2018 11:40
Show Gist options
  • Save Yaromaxx/05c83430699593ed1276b83d1b5a3fb3 to your computer and use it in GitHub Desktop.
Save Yaromaxx/05c83430699593ed1276b83d1b5a3fb3 to your computer and use it in GitHub Desktop.
Fix_printers_errors_on_terminal_server
@echo off > nul
:: Script to fix printers errors on terminal and print servers
:: run as administrator on terminal server
net stop spooler
:: remove old print tasks
del %systemroot%\system32\spool\printers\*.shd /F /S /Q
del %systemroot%\system32\spool\printers\*.spl /F /S /Q
:: make backup folder if not exist
if not exist %systemroot%\System32\spool\prtprocs\x64_bak\ md %systemroot%\System32\spool\prtprocs\x64_bak\
:: backup *.dll
xcopy /y /r /h %systemroot%\System32\spool\prtprocs\x64\*.dll %systemroot%\System32\spool\prtprocs\x64_bak\
:: remove old folder
rd /s /q %systemroot%\System32\spool\prtprocs\x64\
:: copy *.dll to new folder
md %systemroot%\System32\spool\prtprocs\x64\
xcopy /y /r /h %systemroot%\System32\spool\prtprocs\x64_bak\*.dll %systemroot%\System32\spool\prtprocs\x64\
:: remove PendingFileRenameOperations
REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations
if %ERRORLEVEL% EQU 0 REG DELETE "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /f
net start spooler
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment