'How to I prevent vscode from opening while running a file in startup

Hi

I made a simple app to always run on start up.

Here is the script:

import os
import webbrowser
import tkinter as tk
from tkinter import Canvas

wifiURL = 'https://168.1.254:8090/httpclient.html'
chromePath = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google Chrome.exe'

def PlayGame():
    os.startfile("C:\Customization\Games shortkuts")

def MakeGames():
    os.startfile("C:\Customization\Gamedev shortkuts")

def LoginWIFI():
    webbrowser.get('C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google 
Chrome.exe %s').open(wifiURL)


root = tk.Tk()

Canvas = tk.Canvas(root,bg="Gray")
Canvas.pack()

Login = tk.Button(Canvas, text="Login", padx= 50, pady=0.8, command=LoginWIFI)
Login.pack()

PlayGames = tk.Button(Canvas, text="Play Games", padx=50,pady=0.8,command=PlayGame)
PlayGames.pack()

GameDev = tk.Button(Canvas, text="Game development", padx=50,pady=0.8,command=MakeGames)
GameDev.pack()

root.mainloop()

To run it every time on startup I made a shortcut and copied it to the startup folder 📂.

But every time I open my computer, instead of running the program it opens vscode. To prevent that I changed the default application for .py files to python.exe but it is still showing the same behaviour.

Please help.



Solution 1:[1]

if python is installed in C:\python and your script is C:\pythonscripts\myscript.py, create a shortcut running

C:\Python\python.exe C:\pythonscripts\myscript.py

And place the shortcut in your startup folder

Solution 2:[2]

Right click the file, select "open with", select "choose another app" at the bottom, select "Python", and check "always use this app" at the bottom

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David
Solution 2 MingJie-MSFT