Skip to content

Commit

Permalink
Update Universalator.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
Git-North authored Jan 7, 2025
1 parent 61dd9e0 commit 09c4a2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Universalator.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

@ECHO OFF
:: if you are gonna do any automation/scripting do it between here
:scriptingStart
Expand Down Expand Up @@ -949,7 +950,7 @@ IF /I !OVERRIDE!==J (
:: Looks inside the 'release' file for later information display. If all found folders are old, or there are no found folders, script continues on.
ECHO: & ECHO Checking for system installed Java !JAVAVERSION! less than !MONTHS_OLD! months old... .. .

FOR /F "delims=" %%A IN ('powershell -Command "$ver='!JAVAVERSION!'; $MonthsAgo = (Get-Date).AddMonths(-!MONTHS_OLD!); $paths = @('C:\Program Files', 'C:\Program Files\Java', 'C:\Program Files\Eclipse Adoptium', 'C:\Program Files\Eclipse Foundation', 'C:\Program Files\Amazon Corretto', 'C:\Program Files\Zulu'); foreach ($p in $paths) { if (Test-Path $p) { Get-ChildItem $p -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^(jdk-?'+$ver+'|temurin-?'+$ver+'|jre-?'+$ver+'([\.0-9]+[-]?)*|zulu-?'+$ver+'|jdk1\.'+$ver+'|java-?'+$ver+'|openjdk-?'+$ver+')([-_].*)*$' } | ForEach-Object { $ageTag = if ($MonthsAgo -gt $_.CreationTime) { 'old#' } else { 'new#' }; $ageTag + $_.FullName } } }"') DO (
FOR /F "delims=" %%A IN ('powershell -Command "$ver='!JAVAVERSION!'; $MonthsAgo = (Get-Date).AddMonths(-!MONTHS_OLD!); $paths = @('C:\Program Files', 'C:\Program Files\Java', 'C:\Program Files\Amazon Corretto', 'C:\Program Files\Zulu' 'C:\Program Files\Eclipse Adoptium', 'C:\Program Files\Eclipse Foundation'); foreach ($p in $paths) { if (Test-Path $p) { Get-ChildItem $p -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^(jdk-?'+$ver+'|temurin-?'+$ver+'|jre-?'+$ver+'([\.0-9]+[-]?)*|zulu-?'+$ver+'|jdk1\.'+$ver+'|java-?'+$ver+'|openjdk-?'+$ver+')([-_].*)*$' } | ForEach-Object { $ageTag = if ($MonthsAgo -gt $_.CreationTime) { 'old#' } else { 'new#' }; $ageTag + $_.FullName } } }"') DO (

FOR /F "tokens=1-2 delims=#" %%B IN ("%%A") DO (
IF /I "%%B"=="new" IF EXIST "%%C\bin\java.exe" (
Expand Down

0 comments on commit 09c4a2b

Please sign in to comment.