문제

I am trying to create a Python program that uses the os.system() function to create a new process (application) based on user input... However, this only works when the user inputs "notepad.exe". It does not work, for instance, when a user inputs "firefox.exe". I know this is a path issue because the error says that the file does not exist. I assume then that Windows has some default path setup for notepad that does allow notepad to run when I ask it to? So this leads to my question: is there any way to programmatically find the path to any application a user inputs, assuming it does in fact exist? I find it hard to believe the only way to open a file is by defining the entire path at some point. Or maybe there's a way that Windows does this for me that I do not know how to access? Any help would be great, thanks!

도움이 되었습니까?

해결책

I think you can add the location of the files in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';' (without quotes) and then add the absolute path of the .exe file which you want to run via your program.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top