3

I'm trying to install VirtualBox from an electron app to the host machine.

Currently I do the following:

(virtualbox installer is packaged in the electron app)

await util.sudoExec(`
  copy ${app.getAppPath()}\\..\\resources\\installers\\VirtualBox-6.1.8-137981-Win.exe ${temp}\\pkg.exe &
  ${temp}\\pkg.exe /extract --silent &
  msiexec /i ${temp}\\VirtualBox\\VirtualBox-6.1.8-r137981.msi /quiet /norestart ALLUSERS=2 VBOX_INSTALLDESKTOPSHORTCUT=0 VBOX_INSTALLQUICKLAUCHSHORTCUT=0
`)

The above code is working 70%. In some cases I got an error message ie.:

'C:\Users\Username\AppData\Local\Temp\pkg.exe' is not recognized as an internal or external command,
operable program or batch file.

I'm not sure this is the best way to install VB.

Peter Kota
  • 8,048
  • 5
  • 25
  • 51
  • 1
    can you define what " In some cases" is? are there any spaces in the path (space in username?)? – Tobias Aug 14 '20 at 19:57
  • Tangentially, is `util.sudoExec` from a library, or something you implemented yourself? Seems like something I might be able to use in my own work, and a bit of googling didn't turn it up. – JakeRobb Aug 20 '20 at 00:58

2 Answers2

1

You could try to use Chocolatey:

This will install it:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

And this command will install Virtualbox:

choco install virtualbox -y

This would also allow you to easily update the software whenever you need to. It's an option so you don't need to maintain package installers for each version of VB.

1

There is an answer , I think it could help you

'' is not recognized as an internal or external command, operable program or batch file

see the answer of Gerhard on this question

Medhat Mahmoud
  • 512
  • 1
  • 5
  • 25