Automate Starting Up the Internet Browser in Windows by using Task Scheduler and Python

Automate Starting Up the Internet Browser in Windows by using Task Scheduler and Python

Overview

This short article will show how to automatically start the internet browser when powering on a Windows computer. This is done by configuring a Windows program called "Task Scheduler" to run a Python script that automatically opens the internet browser. This tutorial will demonstrate using Microsoft Edge and this method can work with any other internet browser.

Materials

  • Windows

  • Internet Browser

  • Command Prompt, Windows Powershell or an IDE

  • Python

  • Task Manager

Procedure

Step 1: Find the Internet Browser File Path

In Windows, find the path of the internet browser. An easy way of finding the path is to right-click the browser desktop icon and select "Properties".

Observing "Properties" shows the locations of the necessary files to start the internet browser within "Start in". Navigate to the file path that "Start in" specifies with administrator privileges.

Step 2: Create the Python Script

Create a Python script:

nano start_internet.py
#!usr/bin/env python3
# start_internet.py script

import os
# os module enables Python to interact with different directories and to change into different directories

change_directory = os.chdir(r"insert_file_path")
# chdir - change directory to specified directory
# insert_file_path is the same file path that is specified by "Start in" internet browser properties

start_new_internet_tab = os.startfile("msedge.exe")

# For every internet browser, an ".exe" file must be executed. For Microsoft Edge, it is called "msedge.exe"

To test if the script works, run it and a new tab should appear:

python start_internet.py

Step 3: Automate the Computer to begin a new Internet Browser Tab upon Startup

Windows has a program called "Task Scheduler" that looks like this:

Open "Task Scheduler". Upon opening it, displays a variety of options. To the right of the screen, there is an "actions" menu and an option "Create Task". Select it.

Upon opening "Create Task" always brings up the "General" menu by default. Give a rememberable name to the task and configure it for your operating system. If the Windows operating system is not specified, select the one that is closest to the current Windows version.

Switch to the "Triggers" tab and click "New". There are many options to choose from "Begin the task". Since this script will be customized to run once when starting up the computer, select the option "At startup" and click "OK".

Now, switch to the "Actions" tab and select "New". Click the "Browse" button and under "Program/script" insert the path for "Python.exe" and under "Add arguments (optional):" insert the file path that contains the script to run the internet browser. Afterward, select "OK" and then click "OK" once more after making these changes to "General", "Triggers", and "Actions".

Restart the Windows machine and upon startup, a new internet browser tab should appear automatically.

Source Code

https://github.com/AndrewDass1/PROTOTYPE_IDEAS_AND_SCRIPTS/tree/main/Scripts/Start%20Internet