Results 1 to 3 of 3
-
2018-05-03, 19:03 #1
- Join Date
- Dec 2009
- Location
- South Glos., UK
- Posts
- 3,817
- Thanks
- 171
- Thanked 1,073 Times in 850 Posts
AutoHotkey - Clearing Windows' print queue
Long story short... my sister's printer kept hanging but (using TeamViewer) I found it could be kicked back into operation by clearing the print queue.
I adapted a post in the AutoHotkey forums to keep her going until I can hopefully come up with a more permanent solution:
Code:; Based on https://autohotkey.com/boards/viewtopic.php?f=6&t=24987&hilit=print+queue #SingleInstance force ; Ensure only one instance at a time #NoTrayIcon ; Suppress the default icon in the Notification Area ; Prompt to 'Run as Admin', i.e. show UAC dialog If Not A_IsAdmin { Run *RunAs "%A_ScriptFullPath%" ; Requires AHK v1.0.92.01+ ExitApp } ; Show user message to inform what's happening SplashImage,, W300 H120,, `nPlease wait...`n`nThe Printer queue is being cleared.`n`n This may take up to 10 seconds., Clear Printer Queue ; Stop the Print Spooler Runwait, %comspec% /c "net stop spooler",, hide ; Windows has its Print Queue located at the path used below. Runwait, %comspec% /c "del C:\Windows\System32\spool\printers\* /Q /F /S",, hide ; Delete all files in the Print Queue (using [Q]uiet mode, [F]orce and clear [S]ub-folders switches) ; See https://ss64.com/nt/del.html for more info about the DEL command ; Restart the Print Spooler Runwait, %comspec% /c "net start spooler",, hide ; Close the information message splashimage, off ExitApp
printer_queue_being_cleared.png
Hope this helps...
-
2018-05-03, 20:19 #2
- Join Date
- Mar 2004
- Location
- Manning, South Carolina
- Posts
- 10,161
- Thanks
- 450
- Thanked 1,655 Times in 1,488 Posts
Rick,
Here's a PowerShell version that has a Setup switch which will add a scheduled task to run as Admin and a desktop shortcut (which can be moved if you wish) to call it.
It also includes comment based help file.
Just place the script (program) in the directory where you want to run it from and then run the program from an elevated PS session with the -Setup argument.
Clear-PrintSpooler.zip: Clear-PrintSpooler.zip
HTHMay the Forces of good computing be with you!
RG (still RetiredGeek on AskWoody.com)
PowerShell & VBA Rule!
My Systems: Desktop Specs
Laptop Specs
-
2018-05-04, 12:59 #3
- Join Date
- Dec 2009
- Location
- South Glos., UK
- Posts
- 3,817
- Thanks
- 171
- Thanked 1,073 Times in 850 Posts
Originally Posted by RetiredGeek
I'll have to look into creating scheduled tasks from within AHK.