""" wh: a 'where' command that actually is useful on Win32 It understands the PATH and PATHEXT environment variables. Ned Batchelder, http://www.nedbatchelder.com, 10/21/2001 """ import os, os.path, sys path = filter(None, os.environ["PATH"].split(";")) pathext = filter(None, os.environ["PATHEXT"].split(";")) # The command name we are looking for cmdName = sys.argv[1] # Is the command name really a file name? if cmdName.find('.') >= 0: # Fake it by making pathext a list of one empty string. pathext = [''] # Loop over the directories on the path, looking for the file. for d in path: for e in pathext: filePath = os.path.join(d, cmdName + e) if os.path.exists(filePath): print filePath #end.