-
Notifications
You must be signed in to change notification settings - Fork 5
print_queue_clear.ps1
Corey Watson edited this page Dec 19, 2025
·
1 revision
Resets and clears the Windows print queue by stopping the Print Spooler service.
This script resolves common printing issues caused by stuck or corrupted print jobs by stopping the Print Spooler service, removing all queued print jobs from the spooler directory, and restarting the service.
Resets and clears the Windows print queue by stopping the Print Spooler service, removing all queued print jobs from the spooler directory, and restarting the service. Resolves common printing issues caused by stuck or corrupted print jobs.
- Windows 10/11 or Windows Server
- Administrator privileges
- Print Spooler service must exist
-
$serviceName: Name of the Print Spooler service (default: "Spooler") -
$stopTimeout: Maximum seconds to wait for service to stop (default: 30) -
$startTimeout: Maximum seconds to wait for service to start (default: 30)
- Validates hardcoded input values
- Checks current status of Print Spooler service
- Stops the Print Spooler service and waits for handles to release
- Removes print job files with retry logic (3 attempts per file)
- Reports successfully removed and locked files separately
- Restarts the Print Spooler service
- Verifies service is running and reports final status
- No secrets in logs
- Requires elevated privileges
- Only deletes files from Windows spooler directory
- 0 = Success
- 1 = Failure
[ SERVICE STATUS CHECK ]
--------------------------------------------------------------
Service : Spooler
Status : Running
[ STOPPING PRINT SPOOLER ]
--------------------------------------------------------------
Stopping service Spooler
Service stopped successfully
[ CLEARING PRINT QUEUE ]
--------------------------------------------------------------
Spooler Directory : C:\Windows\System32\spool\PRINTERS
Total Files Found : 5
Files Removed : 5
Queue cleared successfully
[ STARTING PRINT SPOOLER ]
--------------------------------------------------------------
Service started successfully
[ FINAL STATUS ]
--------------------------------------------------------------
Result : Print queue cleared and service restarted successfully
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
- 2024-12-01 v1.1.0 - Migrated from SuperOps - added retry logic for locked files
- 2025-01-17 v1.0.0 - Initial release
- View Script Source
- Scripts - Back to script index