Auto-start

Asked

Viewed 1,649 times

0

I have a program in Python and I need it to start automatically along with Windows, I could not find any material related to it on the internet.

  • What versions of Windows? You can guarantee that Python 3 will be installed on the machines where this program will auto-boot?

  • Windows 7, in case, the program will be ". exe", so it would not need the interpreter installed.

  • the word Startup does not exist

  • http://www.dicio.com.br/startup/ Serious?

2 answers

1

Click on Start Menu > All programs > Initialize

In English: Start Menu > All programs > Startup

Inside the boot folder, put the shortcut of your file .bat which will open your python program when you start Windows.

To create the archive .bat you can open the notepad and type this:

start Python caminho

In place of path you place where your python file is .py. If the file is in the same folder as the file .bat just enter the file name. Example:

teste.py

Otherwise, you put the whole way, example:

start Python C:/Users/User/Desktop/teste.py

When saving as, don’t forget to save as file .bat: start.bat for example. Here is explaining a little about files .bat if you need to.

If it doesn’t work, check if the Python is in the system path.

1

  1. Press Win+R to open the "Run..." menu;
  2. Type "shell:Startup" to open the "Initialize" folder.

Any program whose shortcut you drag to that folder will run when Windows boots.

(If you need parameters by the command line for the program, you will need to create a file .bat do so.)

  • I need Python to do it himself?

  • 1

    Apparently os.environ['CSIDL_STARTUP'] is the right directory; you can make your program copy yourself there and.g. shutil.copyfile(sys.argv[0], os.path.join(os.environ['CSIDL_STARTUP'], os.path.basename(sys.argv[0]))

  • I think I got a base, thanks for the help ctgPi.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.