# Clear gateway printer queue via button

**URL:** <https://forum.inductiveautomation.com/t/clear-gateway-printer-queue-via-button/91424>\
**Category:** Ignition\
**Tags:** python, ignition81, scripting, perspective\
**Created:** [June 5, 2024, 5:00pm UTC](https://forum.inductiveautomation.com/t/clear-gateway-printer-queue-via-button/91424 "2024-06-05T17:00:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Leech](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex_leech/32/39391_2.png) [@Alex\_Leech](https://forum.inductiveautomation.com/u/Alex_Leech)\
**Post date:** [June 5, 2024, 5:00pm UTC](https://forum.inductiveautomation.com/t/clear-gateway-printer-queue-via-button/91424/1 "2024-06-05T17:00:49Z")

</div>

Hi all!

I have need to clear the local print queue on the gateway using a button on a perspective session. TLDR is everytime the printer runs out of ink or paper, it locks up the print queue and backs up till somone fixes the printer, and then clears the queue. The gateway is on a VM the site guys can't / dont want to touch.

I've made a button that writes to a tag with a script to run a batch file - All good.... well except nothing happens!

The batch file is a simple:

```python
net stop spooler
DEL /F /S /Q %systemroot%\System32\spool\PRINTERS\*
net start spooler

```

but I'm guessing because this needs to be run with admin rights, the gateway can't execute it. Anyone got other ideas or know how to fix this issue? 🙂

Thanks!  
Alex

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 5, 2024, 5:03pm UTC](https://forum.inductiveautomation.com/t/clear-gateway-printer-queue-via-button/91424/2 "2024-06-05T17:03:28Z")

</div>

See this from five hours ago:

> [@Help making system.util.execute work on Windows](https://forum.inductiveautomation.com/t/help-making-system-util-execute-work-on-windows/91396/2):
>
> Simply not true. Ignition only needs local privileges to run, and that is all it gets when running as the default LOCAL SYSTEM user. The service also has no connection to what you do on the desktop as far as networks are concerned, so your testing in the terminal is insufficient. Instead of using system.util.execute(), which is fire-and-forget, use java's [ProcessBuilder](https://forum.inductiveautomation.com/search?q=ProcessBuilder%20order%3Alatest) so you can collect the output and error streams from your batch file's execution.
