Select to view content in your preferred language

Execute a scheduled python script and suppress the command window

2422
3
12-28-2018 11:44 AM
JoeBorgione
MVP Emeritus

The windows 10 task scheduler has deprecated the use of pop ups.  I have written a couple of tkinter message windows that I'd like to schedule to appear on my desktop.  They work fine, but when I run them as a scheduled task, the python window appears as well as the tkinter message.  I'd like just to see the message and no python window.

How to Execute Python Script using Windows Scheduler - Data to Fish  provides a step by step how-to wrap a python script in a .bat file; doesn't seem to work for me, and I wonder if it's a windows 10 thing?  

Bottom line; does anyone know how to execute a python script as a scheduled task to open a message on the desktop without a python command window as well?

My .bat file:

@echo off

"C:\Users\JBorgione\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\python.exe" "J:\PythonDevelopment\PopUps\GetUpReminder3.x.py"

The actual tkinter message script:

import tkinter
from tkinter import messagebox
 
# hide main window
root = tkinter.Tk()
root.withdraw()
 
# message box display
messagebox.showinfo("Movement", "Get Up and Take a Walk")

 the results:

I've tried to run it with windows 2.7python and both 2.7 and 3.x pythonw.exe to no avail....

That should just about do it....
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

try pythonw.exe instead of python.exe

0 Kudos
JoeBorgione
MVP Emeritus

I did, but no workee for me-me...   I'll try again though...

(moments later)

Initially, it did the same thing, but I hadn't renamed my python script to .pyw.

Now I've renamed it to .pyw and all I get is a flash...

Sigh.

That should just about do it....
0 Kudos
curtvprice
MVP Esteemed Contributor

Have you tried start /b in your .bat file?

https://www.windows-commandline.com/cmd-start-command/