0

I'm using this command that I added to my PowerShell script and would like to know if there is anything wrong if I use it I saw I added some configuration to it and it seems it installs properly as well in the right path but I'm unsure if there is anything else that I need to look for?

Start-Process 'C:\Magtek\jre-8u301-windows-x64.exe' -ArgumentList 'INSTALL_SILENT=Enable REBOOT=Disable SPONSORS=Disable' -Wait -PassThru
Olaf
  • 4,690
  • 2
  • 15
  • 23
  • 1
    I don't get it. Do you have any problem with the installation or with the installed Java? – Olaf Aug 24 '21 at 22:18
  • I guess I'm asking if that is the correct way to set up a silent install command for java in PowerShell I was reading that sometimes it doesn't properly install and could have issues with the registry. –  Aug 24 '21 at 22:21
  • Did you try if it works as expected? If "no" - do it now. If it does - happy day. ;-) – Olaf Aug 24 '21 at 22:27

1 Answers1

1

You don't need to use Start-Process in this case. Simply call the .exe using the call operator or dot sourcing.
Like this:

& 'C:\Magtek\jre-8u301-windows-x64.exe' INSTALL_SILENT=Enable REBOOT=Disable SPONSORS=Disable  

Now, if the installation parameters are right is a whole different story.
Please, refer to the installer options.

Compo
  • 36,585
  • 5
  • 27
  • 39
FranciscoNabas
  • 505
  • 3
  • 9
  • Indeed, there's _usually_ no reason to use `Start-Process`. However, there are applications with CLIs that are _GUI-subsystem_ applications, notably `msiexec.exe` (I don't know if `jre-8u301-windows-x64.exe` is), which PowerShell runs _asynchronously_ by default; `Start-Process -Wait` makes sense to ensure their _synchronous_ execution. The OP's own attempt has a _syntax problem_ however, which is discussed [in their follow-up question](https://stackoverflow.com/q/69093794/45375), alongside a shortcut to synchronous GUI-application invocation by piping a direct call to `Write-Output`. – mklement0 Sep 08 '21 at 17:16