How to Get Printer Queue Status in Batch Script
In a busy office or high-volume warehouse, a stalled printer is more than a nuisance: it's a workflow bottleneck! If a printer runs out of paper, has a paper jam, or loses its network connection, the Print Queue can quickly fill up with "Ghost" jobs that are stuck in limbo. Manually checking the "Printers & Scanners" settings for every workstation is inefficient. A Batch script can use the WMIC (Windows Management Instrumentation Command) or PowerShell to query the real-time status of your printer queues, allowing you to build automated alerts that notify you the moment a printer goes offline.
This guide will explain how to audit printer queue status using Batch.
Method 1: The Quick Queue Check (WMIC)
WMIC is the most direct way to get a text-based summary of your printers.
@echo off
echo [AUDIT] Fetching printer status...
echo.
:: List all printers and their current 'PrinterStatus' code
:: Common status codes:
:: 1 = Other, 2 = Unknown, 3 = Idle (OK)
:: 4 = Printing, 5 = Warming Up, 6 = Stopped
:: 7 = Offline
wmic printer get Name, PrinterStatus, WorkOffline
if %errorlevel% neq 0 (
echo.
echo [ERROR] Failed to query printers. The Print Spooler service may be stopped.
)
echo.
pause
Method 2: Detecting "Offline" Printers
This script specifically looks for printers that have the WorkOffline flag set to true, which is the most common cause of failed print jobs.
@echo off
echo [SCAN] Searching for offline printers...
echo.
:: Capture WMIC output to check if any offline printers were found
set "FoundOffline=0"
for /f "skip=1 tokens=*" %%a in ('wmic printer where "WorkOffline=TRUE" get Name 2^>nul') do (
set "line=%%a"
if defined line (
echo [OFFLINE] %%a
set "FoundOffline=1"
)
)
if "%FoundOffline%"=="0" (
echo [OK] All printers appear to be online.
) else (
echo.
echo [ALERT] One or more printers are offline. Check connections and power.
)
echo.
pause
Method 3: Counting Jobs in the Queue (PowerShell Bridge)
If you want to know how many documents are stuck, PowerShell provides a much cleaner count.
@echo off
echo [STATS] Counting pending print jobs...
echo.
powershell -NoProfile -Command ^
"$printers = Get-Printer 2>$null;" ^
"if (-not $printers) { Write-Host '[INFO] No printers found on this system.'; exit };" ^
"$printers | ForEach-Object {" ^
" $jobs = (Get-PrintJob -PrinterName $_.Name -ErrorAction SilentlyContinue);" ^
" $count = if ($jobs) { @($jobs).Count } else { 0 };" ^
" [PSCustomObject]@{ Name = $_.Name; Status = $_.PrinterStatus; Jobs = $count }" ^
"} | Format-Table Name, Status, Jobs -AutoSize"
echo.
pause
How to Avoid Common Errors
Wrong Way: Assuming "PrinterStatus=3" means the printer is physically perfect
A status of 3 (Idle) means the Windows Spooler thinks everything is fine. However, a printer might still be "Idle" even if it has a physical "Low Toner" light blinking on the machine itself.
Correct Way: Use Method 3 to check the Job Count. If a printer is "Idle" but has 10 jobs in its queue, it is effectively broken, regardless of its reported health status.
Problem: WMIC Deprecation
In future versions of Windows 11, WMIC might be disabled by default.
Solution: Switch to the PowerShell bridge (Method 3). It is the modern standard for hardware and device management in Windows.
Best Practices and Rules
1. Identify "Stuck" Spooler
Sometimes the printer is fine, but the Print Spooler service on your PC has crashed. If your script returns "No Instance(s) Available," try restarting the service:
net stop spooler && net start spooler
2. Monitor Network Shared Printers
If your script is running on a server, use it to monitor shared queues. If a specific user's print job is blocking everyone else, your script can detect the "Job Count" spike and alert you.
3. Log the Availability
Run this script every hour and log your "Uptime" for office printers. This data is invaluable when deciding which printer models are reliable and which ones need to be replaced.
wmic printer get Name, PrinterStatus >> printer_health_log.txt
Conclusions
Getting the printer queue status via Batch script transforms your local hardware management from reactive "Firefighting" into proactive monitoring. By moving away from manual GUI checks and utilizing automated status queries, you gain the ability to resolve printing issues before they disrupt your department. This professional oversight is essential for anyone maintaining high-productivity Windows environments where document flow is critical to business success.