Python Windows login script

Python Windows login script

Spread the love

Python Windows login script

As I have been learning Python recently I decided to write a Python script get my Windows 10 laptop ready to work without any physical interaction. Again this is a really basic script but it frees up 5 to 10 minutes of my morning and means that I have less menial tasks to complete in the morning.

What the script does:

I thought about what I do after I have logged into my laptop in the morning and I then listed what I did and in what order which was:

  1. log into my OpenVPN VPN
  2. Open Google Chrome and log into a bunch of webpages (Github, helpdesk, webmail, wiki etc)
  3. Open a WSL2 window
  4. Open Outlook (Plan to scrape outlook later to save more time)
  5. Open slack
  6. Open Teams

The script:

Once I had all the activities that I needed I set about working through and automating the tasks one by one. After about an hour I had a working script:

# ITHOWTOO Startup Script

# Load modules:
import os
import webbrowser

## VPN
# Connect to VPN
openvpn =r'"C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect config.ovpn'

## Chrome
url = '' # Open Github
url1 = '' # Open
url2 = '' # Open Gmail:
url3 = '' # Open Google:

## WSL2

# Open New Window

## Outlook
# Scrape new emails

# Open Outlook

## Open Slack
# Replace USERNAME wit real username
slack =r'"C:\Users\USERNAME\AppData\Local\slack\slack.exe"'

## Open Teams

As I said the script is pretty basic amd only uses 2 modules to get the job done (OS module and webbrowser module).

GitHub Project

The script is now on my github so when I add more things to it the github will be updated:

ithowtoo/ Startup Script (

Automating the script:

Once the script has been editied to get everything working that is needed it needs to be copied to:

C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Obviously USERNAME needs to be replaced with the correct user name.

Once the script is in the start-up folder it will automatically run on the next boot.

Over-ride default wait to run script:

On Windows 10 there is a default GPO that makes the machine wait 5 minutes to run startup scripts to let the machine boot before the scripts are run.

This behaviour can be changed using the following Microsoft article:

Logon scripts don’t run for five minutes – Windows Client | Microsoft Docs

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top