I am making a program that will be able to open programs such as discord, google chrome, epic games launcher, steam, etc. How would I go about finding where the programs are installed on the device (Windows 10). I have done a bit of research and there is a thing called the Windows registry but I don't know how to make it so you can get the .exe file to launch the program.
from tkinter import *
def WindowCentre():
positionRight = int(Main.winfo_screenwidth() / 2 - 960 / 2)
positionDown = int(Main.winfo_screenheight() / 2 - 540 / 2)
Main.geometry("+{}+{}".format(positionRight, positionDown))
def ButtonClick(Application):
# Whatever the code is for here
# pass is just for the error
pass
Main = Tk()
Main.title("Program Launcher")
# Main.iconbitmap("")
Main.configure(bg="#2c2f33")
Main.geometry("960x540")
WindowCentre()
DiscordImage = PhotoImage(file="Images/Discord Icon.png")
DiscordButton = Button(image=DiscordImage, activebackground="#2c2f33",
activeforeground="#2c2f33", bg="#2c2f33",
width=150, height=150, borderwidth=0,
command=lambda: ButtonClick("Discord"))
DiscordButton.grid(row=0, column=0, padx=10, pady=10)
EpicGamesImage = PhotoImage(file="Images/Epic Games Launcher Icon.png")
EpicGamesButton = Button(image=EpicGamesImage, activebackground="#2c2f33",
activeforeground="#2c2f33", bg="#2c2f33",
width=150, height=150, borderwidth=0,
command=lambda: ButtonClick("Epic Games Launcher"))
EpicGamesButton.grid(row=0, column=1, padx=10, pady=10)
Main.mainloop()
So how can I make the program find where the program is installed on any windows device and then make a button on the gui open it when clicked? I could just use default directory but most programs have the option to change install location, so I am looking for a method of finding the programs install location.
Thanks for anyones help!
EDIT
I was wondering if this would work with launching the program? Windowsapps finds the AppID of the exe. I don't know how to use this to launch the program, can anyone help make sense of it?
import windowsapps
name, appid = windowsapps.find_app('Discord')
#searches for the APPLICATION NAME and returns:-
#name = Name of the application.
#appid = AppId of the application
print(name)
print(appid)