Python Forum
run python file on background and start on windows boot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
run python file on background and start on windows boot
#1
I want to run my python file on background and start it when my windows boots,
I have reference site from this https://stackoverflow.com/questions/3113...in-windows, but I have no idea how to do with it.
can you guys tell me how to get rid my problem?

thanks in advance
Reply
#2
Fyi ..

https://stackoverflow.com/questions/4438...ows-starts

Useful tips:
Find diff bet pythonw.exe and python.exe

"If you don't want a terminal window to pop up when you run your program use pythonw.exe;
Otherwise, use python.exe"
Reply
#3
couple of options
1. put a link to your python file in shell:startup folder (i.e. no need to use bat file, unless you want to)
2. You can use Task Scheduler to set up a task that will start the script at login
Reply
#4
(Dec-19-2017, 06:33 AM)Venkatkrish Wrote: Fyi ..

https://stackoverflow.com/questions/4438...ows-starts

Useful tips:
Find diff bet pythonw.exe and python.exe

"If you don't want a terminal window to pop up when you run your program use pythonw.exe;
Otherwise, use python.exe"

I have been browsing but I found nothing,
how to use pythonw.exe to run my python file?
note that I use python 3.

(Dec-19-2017, 09:13 AM)buran Wrote: couple of options
1. put a link to your python file in shell:startup folder (i.e. no need to use bat file, unless you want to)
2. You can use Task Scheduler to set up a task that will start the script at login

where is shell:startup?
Reply
#5
type it in the windows explorer address bar.
or from start menu ->run->shell:startup
Reply
#6
(Dec-22-2017, 03:08 PM)buran Wrote: type it in the windows explorer address bar.
or from start menu ->run->shell:startup

OK, I've found it..
so, how to make a link into it or use a batch file?
can I just copying my whole python file into it?
I am sorry, I really new to this.
Reply
#7
A batch file is just a series of commands to be executed in the command line. If you have ever executed your script from the command prompt you already know all you need.
Create a text file and write down the steps you would follow to execute your python script:
1. You change the directory to where the script is located.
2. run the script
So your text file would look something like this:
Quote:cd C:\\Users\\Location_of_script
python script.py
Then rename the text file with a '.bat' extension. Now put this file in the startup folder.

Points to note:
1. Ensure that Python is added as an environment variable
2. Batch files are wonderful for a multitude of other things. Check it out!
Reply
#8
you can go with bat file, as suggested
or you can just create a link (shortcut)
Right-click -> New -> Shortcut

In the window that opens, write (or browse to find) the path to your python.exe. That will be in the top folder where you have installed python. Add full path to your script. So it will look like
c:\python3\python.exe c:\pathtoyourscript\yourscript.py

on the next window name your shortcut whatever youlike
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ## Its part of my boot camp Task Raselrameda 7 2,712 Feb-14-2022, 05:20 PM
Last Post: Raselrameda
  As a new to Python & Hadoop I don't know where to start, I need your suggestion chanduporeddy 1 1,468 Oct-04-2019, 06:52 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020