# save first parameter $ARGS = $args $ARG1 = $args[0] # parent dir of this script (should be the getdown app dir) $DIR = Split-Path $MyInvocation.MyCommand.Path -Parent # insert an "-open" parameter to Jalview's ARGS if ARG1 is non-zero-length, and not "open" or starts with a "-" if ( $ARG1.length -gt 0 -and (-not $ARG1.StartsWith("-")) -and $ARG1 -ne "open" ) { $ARGS = "-open " + $ARGS } $APPDIR = $DIR $JAVA = "${APPDIR}/jre/bin/java.exe" $GETDOWNTXT = "${APPDIR}/getdown.txt" if (-not (Test-Path -Path "${GETDOWNTXT}")) { throw "Cannot find getdown.txt" } if (-not (Test-Path -Path "${JAVA}")) { Write-Host "Cannot find bundled java.exe. Using system and hoping for the best!" $JAVA = "java.exe" } $CLASSPATH = (Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s*=\s*(.*)$" | foreach { "$DIR/$($_.Matches.Groups[1].Value)" }) -join ":" Invoke-Expression -Command "${JAVA} -cp ${CLASSPATH} jalview.bin.Launcher $ARGS"