80

When running Hyper-V and a virtual machine (also with a modern Windows OS), is it really not possible to copy/paste files across between host and VMs? Not even text it seems, although there is a weird "type clipboard text" option, that seems to only work sporadically.

I must be missing something.

I run Windows 8.1 as host and Windows 7 in the VM if that matters.

Kjensen
  • 6,814

8 Answers8

56

Here is a quick and easy way to get this work efficiently:

  • If you're running the VM, turn it off first.
  • find your virtual hard disk image file .vhd of your VM
  • Right click on this file and select mount
  • This will give "System Reserved" and "Local Disk" drives.
  • Open the "Local Disk" drive (this is the OS drive on VM)
  • Go there and paste you files.
  • Finally unmount or eject one of the drivers
  • Run the VM and go the c:\ drive there and you will find your files.

Hope this helps someone :)

Hazem Abdelwahab
  • 679
  • 1
  • 5
  • 4
22

Your best options are a plain old network copy and Remote Desktop, which instead allows full clipboard transfers.

RDP can get quite flaky if you try to copy big files over it, thus if big file transfers are required I'd recommend the network; if you just need to copy/paste some text, RDP works great.

Of course, for both options to work, you need the guest system to be connected to your network and have proper TCP/IP settings.

Brown
  • 1,682
Massimo
  • 2,679
9

According to this StackOverflow answer it does matter what the guest OS is:

ESM only works with Windows 8.1 and Windows Server 2012 R2 VMs. Since you're using a Win7 VM, ESM isn't going to be available.

Although the accepted answer here says there is no way to copy and paste things, I can do it between my Windows 8.1 host and Windows 10 Tech preview running in Hyper-V with ESM. I have yet to find the Windows 8.1 documentation that explains it, but for Server 2012R2 see this TechNet article.

Edit: I found this very practical guide on ESM, which clarified that you also need the Pro or Enterprise versions.

Ian W
  • 288
6

It can be done via Powershell.

First, create a session with New-PSSession from the HOST:

$s = New-PSSession -VMName <VMName> -Credential (Get-Credential)

Then, from the HOST, copy the file via Copy-Item using the session:

Copy-Item -ToSession $s -Path C:\host_path\data.txt -Destination C:\guest_path\

See Copy files with New-PSSession and Copy-Item for details.

Brown
  • 1,682
3

You can "burn" your files to an ISO file on the host and mount the ISO on the guest.

Windows is not able to create ISOs natively, but you can use something like *InfraRecorder (GNU GPL licensed) to create the ISO.

If you end up using InfraRecorder the create ISO action is buried in the top menu under:

Actions > Burn Compilation > to a Disc Image...


* I have no affiliation to InfraRecorder, I just needed to copy some files to a guest.

Jane Panda
  • 1,237
1

I have a weird problem with Copy Paste in Hyper-V, where I can copy paste after starting the VM, but if I log out of the VM OS and log back into the VM as another user, copy paste doesn't work. I found out that the Enhanced session tick in the Virtual Machine Connection window was getting removed, either shortly after I logged in or during the switch between users in the VM. I re-enabled the Enhanced Session tickmark and after that the Copy Paste function in Hyper-V works again.

gakera
  • 445
0

NOTE: The question has two parts to it. The FIRST part asks "How to COPY-PASTE FILES". THIS is an answer to that part of the question. (The SECOND part asks how to copy/paste TEXT; e.g. a clipboard operation. This answer is NOT about that.)

Also see these other answers relevant to copy/paste files, in specific situations:
For ESM-compatible VMs
For initial setup before starting your VM


Files can be copy/pasted between a MAC and a PC, or a LINUX box and a PC, and the same technique can be used between a virtual machine (even using "Version 1", to run older Windows, in my case Windows 7) and its host PC.
How? Network sharing aka "Share a folder over a network".

KEY POINT: Once you have set up a shared folder, you can then do regular file-copying in a Windows Explorer view on the host PC, even if the source is on host and the destination is on VM, or vice-versa. That is, Network sharing is not just about making a set of network files visible on the VM, it also makes it easy for you to later move individual files, or complete folders, between two different computers (here, the VM is one of the computers), as if they were on a single computer.


  • Hyper-V Manager - Virtual Switch Manager.
    • Create Virtual Switch / External
  • Hyper-V / Your VM / Settings
    • Network Adapter / Virtual Switch = the External Virtual Switch from above
  • Boot your VM, login with an Administrator account.
  • Do what you normally do to "Share a folder over the network". (See documentation for the OS you are running on the VM.) In my case, I shared my username/Documents folder. specify read/write privilege, if you want to copy files both to and from that folder
  • Host machine / Windows Explorer / Network / your VM should appear with that shared folder.
    • Select your VM (its "Network" representation), and LOGIN with your VM's administrator account.
    • Copy / Paste files in this Explorer window on your host.

NOTE: I only tested with my user account / Documents folder, so I do not know whether there are limitations on what can be shared. I assume it works exactly the same as any other network sharing from the virtual OS, so it shouldn't matter that it is virtual. It is just another machine on your network, running that OS.

I also did not test with a Linux VM, however I did test with Windows 7, running "Version 1" VM - that works, so any OS that can be run under Hyper-V, and that supports network sharing with Windows, should work.

0
  1. On the VM machine open the Windows Group Policy Editor
    Type gpedit.msc in the Windows Run dialog Win+R
  2. Navigate to the folder "Device and Resource Redirection"
    Computer Configuration
          >  Administrative Templates
               >  Windows Components
                    >  Remote Desktop Services
                         >  Remote Desktop Host
                              >  Device and Resource Redirection
  3. Set the policy to Not configured or Disabled to allow file copy redirection in Remote Desktop Services and Hyper-V Enhanced Session Mode sessions.
Blindspots
  • 3,472
gandreoti
  • 21
  • 3