Error E_ACCESSDENIED trying "vboxmanage list vms" from Python script in Jenkins

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Posts: 1
Joined: 2. Nov 2020, 01:54

Error E_ACCESSDENIED trying "vboxmanage list vms" from Python script in Jenkins

Post by JimeMC »

Hi all,

I'm trying to run a Job in Jenkins that executes a Python script that lists and exports my virtual machines, using the command-line tool vboxmanage, in Windows 7. So, I created a Jenkins agent, and installed it as Windows service and changed the service logon credentials to be my personal account. I checked that the service runs with my account in the services list.

But, when the job is run by the agent, it prints out:

VBoxManage.exe: error: Failed to create the VirtualBox object! VBoxManage.exe: error: The object is not ready
VBoxManage.exe: error: Details: code E_ACCESSDENIED (0x80070005), component VirtualBoxClientWrap, interface IVirtualBoxClient
comand: "C:\Program Files\Oracle\VirtualBox\vboxmanage" list vms

The Python script works well if I run it manually into a CMD window. Also, I used the function os.getlogin() to print out the Windows user that is running the script, and it is correctly my personal user which owns several virtual machines.

I can't guess why I cannot access nor interact with my virtual machines. Any help would be very welcome.
Posts: 1
Joined: 19. Apr 2024, 11:25

Re: Error E_ACCESSDENIED trying "vboxmanage list vms" from Python script in Jenkins

Post by AaronC81 »

I encountered the same issue and managed to resolve it, so I'll answer here for future searchers in my boat!

This was caused by my user not having permissions to launch the VirtualBox Application and/or VirtualBox System Service DCOM objects.

By default, the permissions required to use VirtualBox over COM mean you must be either an interactive user or an administrator. Your Jenkins user is probably neither, so it gets an E_ACCESSDENIED when trying to instantiate the COM object.

It works when you use a Command Prompt because then your user is interactive. (You can run whoami /groups from both a Command Prompt and Jenkins to see how the same user is "treated" differently by the two different environments.)

To change the permissions required:
  1. Open Windows' Component Services
  2. Expand out Computers > My Computer > DCOM Config
  3. Find VirtualBox Application
    1. Right-click > Properties > Security
    2. For each of the three categories, click Edit, add your user, and give it all of the permissions listed
  4. Repeat for VirtualBox System Service
Post Reply