How to search and start an application using python

0

I am developing a code that allows me to find and run any application (for the moment only from the desktop) using python 2.7, using a phrase, this in Windowns 10. Ex: open firefox.

Test code:

import os
def run_prog(self):
    for p in self.frase.split(' '):
        if lambda x: words.items() in p:
            game = self.frase.split(p + ' ')
            dir_path = os.path.dirname(__file__)
            rel_path = os.path.abspath(
                os.path.join(dir_path, "../../../../../public/Desktop/" + str(game[-1]) + ".lnk"))
            try:
                os.startfile(rel_path)
            except:
                print('Cancelado')

I'd like to optimize it and I was able to locate the application anywhere on the PC (when I say locate, it's just find your source folder) instead of just limiting the desktop. Another problem is that applications like Steam games that are different shortcuts, for example, do not work in this case and I could not get them to work by that means.

    
asked by anonymous 09.07.2018 / 00:06

0 answers