DEV Community

Pizofreude
Pizofreude

Posted on

Run Task Scheduler in Silent Mode

Automating mundane task via Task Scheduler is a no brainer.
And making them run in silent mode i.e. not seeing the command prompt pop up every time it runs is a huge win.

For example, if your mundane task is automated via script in a batch file (.bat), you can run your batch file e.g.:(run.bat) in silent mode without the command prompt window popping up.

To do this, you can use the start command along with the /B flag. Here's how you can modify your batch file:

@echo off
# cd \Path\to\YourAutomationProject
cd C:\User\UserName\daily-automation

# Example of task automation with Python
start /B pythonw.exe daily_automation.py
Enter fullscreen mode Exit fullscreen mode

Explanation:

  1. The start command is used to start a separate window to run a specified program or command.

  2. The /B flag is used to start the application without creating a new command prompt window. This is what allows the script to run silently.

  3. Replace python with pythonw.exe. The pythonw.exe is similar to python.exe, but it runs in the background without showing a console window. This helps achieve the silent mode you're looking for.

Please note that the behavior of pythonw.exe can vary depending on the specific Python version you have installed. In some cases, you might need to use python.exe and pair it with other techniques to hide the console window.

Also, ensure that the paths provided in your batch file are accurate and the files are located in the specified directories.

Good luck!
Automation is king.

Top comments (0)