Hello! I am having trouble getting the abspath when entering only an executable file. How can I fix this to return the full abspath? I am taking user input and opening a process (application). Here is my code:

    file = "/" + arr[2] + ".exe"
    path = os.path.abspath(file)
    localtime = time.asctime(time.localtime(time.time()))
    print(arr[2] + " opened at " + localtime + "\n")

When args[2] = 'firefox', this is outputted:

   Traceback (most recent call last):
   File "C:\Python33\lib\subprocess.py", line 1090, in _execute_child
   FileNotFoundError: [WinError 2] The system cannot find the file specified

Any suggestions? Thanks!

Apparently the only way to do this is by searching through windows folders to find the folder that actually contains the executable file. I did this by looping through Windows' Program Files folder to find a folder that contained the same name that the executable had. Actually worked quite nicely.

This question has already been answered. Start a new discussion instead.