Cannot boot Windows guest in VirtualBox without kernel module error

I am on windows 10 and following steps works for me:

Steps:

  1. Navigate to "C:\Program Files\Oracle\VirtualBox\drivers\vboxdrv"
  2. Right click on "VBoxDrv.inf" file and select Install option
  3. Open the Console as a administrator and run the following command

    sc start vboxdrv
    

There's something wrong with the installation of VirtualBox (I've been seeing reports of this problem as far back as 4.x). The installer registers an incorrect location for the driver SYS file (the ImagePath in this example).

PS> Get-ItemProperty HKLM:\system\currentcontrolset\services\vboxdrv


Type         : 1
Start        : 3
ErrorControl : 1
ImagePath    : \??\C:\Program Files\Oracle\VirtualBox\VBoxDrv.sys
DisplayName  : VBox Support Driver
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\system\currentcontrolset\services\vboxdrv
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\system\currentcontrolset\services
PSChildName  : vboxdrv
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry

The file doesn't exist.

PS> Test-Path (Get-ItemProperty HKLM:\system\currentcontrolset\services\vboxdrv).ImagePath
False

The actual location requires an extra drivers\vboxdrv.

PS> Test-Path 'C:\Program Files\Oracle\VirtualBox\drivers\vboxdrv\VBoxDrv.sys'
True

You can update the registered location.

PS> Set-ItemProperty HKLM:\system\currentcontrolset\services\vboxdrv -Name ImagePath -Value '\??\C:\Program Files\Oracle\VirtualBox\drivers\vboxdrv\VBoxDrv.sys'

And now you can start the driver/service.

> sc.exe start vboxdrv