def _find_cmd(cmd):
try:<EOL><INDENT>from win32api import SearchPath<EOL><DEDENT>except ImportError:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>PATH = os.environ['<STR_LIT>']<EOL>extensions = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>path = None<EOL>for ext in extensions:<EOL><INDENT>try:<EOL><INDENT>path = SearchPath(PATH, cmd + ext)[<NUM_LIT:0>]<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if path is None:<EOL><INDENT>raise OSError("<STR_LIT>" % cmd)<EOL><DEDENT>else:<EOL><INDENT>return path<EOL><DEDENT><DEDENT>
Find the full path to a .bat or .exe using the win32api module.