如何打印在Windows环境变量中注册的可运行应用程序路径

18 浏览
0 Comments

如何打印在Windows环境变量中注册的可运行应用程序路径

这个问题已经有了答案在Windows命令行中有没有类似于“ which”的等价物?

假设我在 Windows 系统变量中设置了以下路径信息:

c:\\path\\to\\java\\bin

而我的应用程序是上述路径下的 java.exe

我正在寻找一种使用 Windows 命令提示符获取路径“ c:\\path\\to\\java\\bin”的方法。

admin 更改状态以发布 2023年5月22日
0
0 Comments

我不是Windows或powershell专家,但是一些谷歌搜索给了我Linux功能的whichsed在powershell中的应用..

PS H:\> where.exe java
C:\JDK\1.6.0.31\bin\java.exe
C:\JDK64\1.8.0.45\bin\java.exe
C:\JDK64\1.6.0.31.1\bin\java.exe
C:\JDK64\1.7.0.79\bin\java.exe
C:\Windows\System32\java.exe
PS H:\> where.exe java | %{$_ -replace "[a-zA-Z0-9]+\.exe", ""}
C:\JDK\1.6.0.31\bin\
C:\JDK64\1.8.0.45\bin\
C:\JDK64\1.6.0.31.1\bin\
C:\JDK64\1.7.0.79\bin\
C:\Windows\System32\
PS H:\>

0