How to create a python script that runs automatically at startup (WINDOWS)

So people love automation because it simplifies their lives. Sometimes hosting a script in a proper platform is too much of a hassle / overkill for a simple script. I wondered if there was a way to run a script at windows startup. If all that malware can do it (example recently installed antivirus that installs you 5 more apps from them that start lagging your pc as soon as you turn it on) then I can probably do the same for a simple py script:

First we create a simple script and paste it into a blank .py or .pyw file:

import time 

while True:
    try:
        print("3")
    except:
         print("an error ocurred")
    time.sleep(10)

Then we need to create a .bat file and paste there:

"C:\Python310\python.exe" "C:\Users\fefe\Desktop\Nueva carpeta\test.py"

That's how it looks for me first goes python's path and then paste our script file's path

Let's test it! Everything seems to work fine

image.png

Now we need to make it work at startup:

Press WindowsKey + R
Write shell:startup and press enter again to get startup folder
Then drag/copy your .bat file there

All done!

A few fair warnings:

  1. you need to log in in your pc session for it to start working.
  2. having a script running while you're doing other stuff is quite a bother, there are a many sites that explain how to run them while minimized or on the background: https://www.winhelponline.com/blog/run-bat-files-invisibly-without-displaying-command-prompt/

I have been thinking about a script that would claim hive-engine rewards automatically, so this is probably a good way to get that working.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center