Reputation: 65
Hello!
I was looking for an answer to the question how to run any program from a python script level without knowing the exact path to the program?
Here's an axample:
If I type in my console (console in Spyder or PyCharm)
Open Spotify
Then my program should open Spotify application.
When I was looking for an answer to this question, I only found cases with a specific file location.
Thank you in advance for your time. I'm beginner so sometimes I find it hard to come across to solution.
Upvotes: 0
Views: 107
Reputation: 310
I don't know of a way; as far as I know, you have to know the file location, so to achieve what you want, you need to write some code that will dig through files to find the file location. Ideally, you know the program is contained somewhere in your programs folder (or else it gets harder). os.listdir is a function that can read a folder and list the files inside. You could write a recursive program that looks in your programs folder, checks for spotify, then lists the folder inside it, then checks in each of those...
Upvotes: 1