Last active
September 16, 2019 11:40
-
-
Save mjdorma/9044686 to your computer and use it in GitHub Desktop.
pyvbox: How to copy a file from a VM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""pyvbox: How to copy a file from a VM. | |
""" | |
import os | |
import virtualbox | |
# Assume machine is already running. | |
vbox = virtualbox.VirtualBox() | |
machine = vbox.find_machine("win7") | |
session = machine.create_session() | |
# copy notepad.exe to ./notepad.exe | |
gs = session.console.guest.create_session("mick", "password") | |
gs.copy_from("C:\\Windows\\System32\\notepad.exe", "notepad.exe") | |
gs.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's been an API change in the underlying VirtualBox version; quote from the PDF that comes as part of the VirtualBox SDK, page 390:
Using
copy_to
fails withPatching the sources to call
fileCopyToGuest
instead ofcopyTo
fixes this. However, the file still doesn't seem to get copied; no error message, but no file on the VM either.copy_from
fails with the error message mentioned earlier, despite the fact that the underlying method being called isn't there anymore. Maybe there's a bug in the exception handling somewhere.Patching the sources to call
fileCopyFromGuest
instead ofcopyFrom
doesn't fix this.