问题
I am looking for a way to find out from all installed applications, one that comes with its own java version. There are scripts online to see the version installed on PCs but not the one to get the applications that uses Java and what versions of java they have.
I found something close with using system explorer where I can view all running processes but what i want is a script that can find such applications with the java versions they use and then export the result as csv file or something.
Get-Childitem –Path c:\ -Include java.exe -Recurse -ErrorAction SilentlyContinue | select FullName
I have also written a one line code that kind of shows few applications (2 in my case) but I know there are more.
回答1:
Some java.exe files may be buried inside hidden folders. To also list those, add the -Force
switch. Something like this:
Get-Childitem -Path 'C:\' -Filter 'java.exe' -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object {
[PsCustomObject]@{
'Path' = $_.FullName
'Version' = (Get-Command java | Select-Object -ExpandProperty Version)
'ExeVersion' = $_.VersionInfo.ProductVersion
}
}
来源:https://stackoverflow.com/questions/58375756/powershell-script-to-find-applications-that-come-with-their-own-java-versions