Thanks again for your help. I tried something similar to what you suggested:

def run_app(self, app_path):
    args = shlex.split(app_path.replace("\\", "\\\\"))
    args = [arg.replace("\\\\", "\\") for arg in args]
    args[0] = os.path.expandvars(args[0])
        if pywin32:
            exe = win32api.FindExecutable(args[0])[1]
            if exe != os.path.abspath(args[0]):
                args.insert(0, exe)
    except Exception:
        return False
    return True

where pywin32 is a global variable defined earlier in my program based on 
whether or not the win32api module is available.
This code generally works quite well, but with one problem. I have in my XML 
file a line like this:

<app name="Notepad++" checked="false">%ProgramFiles%\Notepad++\notepad++.exe 

Within the try statement, the variable 'args' contains this list, as expected:

['C:\Program Files (x86)\Notepad++\notepad++.exe', 

But the 'exe' variable returned by win32api.FindExecutable is not what I would 


Because of this, the boolean comparison:

if exe != os.path.abspath(args[0]):

returns True when it should return False, since it is comparing a short 
(MS-DOS) path name with a long path name.
Should I use win32file.GetLongPathName to fix this problem, or do you know of a 
better solution?

-- Timothy

Reply via email to