当前位置:  开发笔记 > 编程语言 > 正文

找到notepad.exe和mspaint.exe的路径

如何解决《找到notepad.exe和mspaint.exe的路径》经验,为你挑选了2个好方法。

找出notepad.exe和mspaint.exe在各种版本的Windows中可以使用的最佳方法是什么?

我应该通过SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, SHGFP_TYPE_CURRENT, dir),然后遍历所有子目录来查找这两个文件吗?

(假设我对Windows文件夹以外的任何内容都不感兴趣.)



1> paxdiablo..:

这适用于我有权访问的每个Windows框(XP +).

c:\> for %i in (cmd.exe) do @echo %~$PATH:i
C:\WINDOWS\system32\cmd.exe

c:\> for %i in (python.exe) do @echo %~$PATH:i
C:\Python25\python.exe

伟大的事情是,你不具备使用实际的%PATH%,你可以通过使用不同的环境变量代替你自己的搜索路径.


notepad.exe仍然是notepad.exe,cmd.exe仍然是我见过的所有语言版本的Windows(98,XP,Vista)中的cmd.exe(大约20个).文件夹的名称可能不同,但可执行文件,库和其他重要内容不会被翻译 - 至少不是文件名.

2> Jason S..:

如果您安装了Microsoft Platform SDK(2003年2月版是最后一个适用于Microsoft VC6的版本),您可以获取该where.exe程序(它是38K,如果你gzip它只有18K)并运行

where notepad.exe

来自where命令的帮助:

WHERE [/R dir] [/Q] [/F] [/T] pattern...

Description:
    Displays the location of files that match the search pattern.
    By default, the search is done along the current directory and
    in the paths specified by the PATH environment variable.

Parameter List:
    /R       Recursively searches and displays the files that match the
             given pattern starting from the specified directory.

    /Q       Returns only the exit code, without displaying the list
             of matched files. (quite mode)

    /F       Displays the matched filename in double quotes.

    /T       Displays the file size, last modified date and time for all
             matched files.

    pattern  Specifies the search pattern for the files to match.
             Wildcards * and ? can be used in the pattern. The
             "$env:pattern" and "path:pattern" formats can also be
             specified, where "env" is an environment variable and
             the search is done in the specified paths of the "env"
             environment variable. These formats should not be used
             with /R. The search is also done by appending the
             extensions of the PATHEXT variable to the pattern.

     /?      Displays this help message.

  NOTE: The tool returns an error level of 0 if the search is
        successful, of 1 if the search is unsuccessful and
        of 2 for failures or errors.

Examples:
    WHERE /?
    WHERE myfilename1 myfile????.*
    WHERE $windir:*.*
    WHERE /R c:\windows *.exe *.dll *.bat
    WHERE /Q ??.???
    WHERE "c:\windows;c:\windows\system32:*.dll"
    WHERE /F /T *.dll

推荐阅读
周扒pi
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有