Find the path of notepad.exe and mspaint.exe

前端 未结 11 1170
后悔当初
后悔当初 2021-01-31 09:45

What is the best way to find out where notepad.exe and mspaint.exe are that will work across various versions of Windows?

Should I get the Windows directory via SHGetFol

11条回答
  •  清酒与你
    2021-01-31 10:08

    This works on every Windows box I've got access to (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
    

    The great thing is, you don't have to use the actual %PATH%, you can substitute your own search path by using a different environment variable.

提交回复
热议问题