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:
- log into my OpenVPN VPN
- Open Google Chrome and log into a bunch of webpages (Github, helpdesk, webmail, wiki etc)
- Open a WSL2 window
- Open Outlook (Plan to scrape outlook later to save more time)
- Open slack
- 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'
os.system(openvpn)
## Chrome
url = 'https://github.com/ithowtoo/' # Open Github
url1 = 'https://www.ithowtoo.com/' # Open ithowtoo.com
url2 = 'https://mail.google.com/' # Open Gmail:
url3 = 'www.google.co.uk' # Open Google:
webbrowser.open_new(url)
webbrowser.open_new(url1)
webbrowser.open_new(url2)
webbrowser.open_new(url3)
## WSL2
# Open New Window
os.startfile("wsl")
## Outlook
# Scrape new emails
# Open Outlook
os.startfile("outlook")
## Open Slack
# Replace USERNAME wit real username
slack =r'"C:\Users\USERNAME\AppData\Local\slack\slack.exe"'
os.startfile(slack)
## Open Teams
os.startfile(r"C:\Users\NB250346\AppData\Local\Microsoft\Teams\current\Teams.exe")
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.py: Startup Script (github.com)
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