VirtualBox bidirectional clipboard sharing stops working after some time on a Linux guest OS
The linux one-liner:
pkill -f VBoxClient; VBoxClient --clipboard
A Windows powershell script.
echo "Trying to restart VBoxClient"
$vbox_process = Get-Process VBoxTray
Write-verbose $vbox_process
$procID = $vbox_process.id
if ($procID -gt 0)
{
$cmdline = (Get-WMIObject Win32_Process -Filter "Handle=$procID").CommandLine
Write-Verbose $cmdline
Write-Verbose "Stopping VBoxTray"
$vbox_process.Kill()
$vbox_process.WaitForExit()
Write-Verbose "VBoxTray stopped"
Write-Verbose "Starting VBoxTray"
Start-Process -FilePath $cmdline.Split(' ')[0]
echo "VBoxTray Restarted. All Done"
} else {
Write-Warning 'Could not find existing vboxTray process. Launching direct?'
Start-Process -FilePath "C:\Windows\System32\VBoxTray.exe"
}
Note: powershell is not really my field of expertise, so I'm expecting some community edits here :)
How to fix shared clipboard in VirtualBox
- In VirtualBox Windows Guest, Open Task Manager
- Go to Processes Tab, highlight VBoxTray.exe and select End Process
- Go to Applications Tab and select New Task
- Browse to the VirtualBox Guest Additions installation folder and select VBoxTray.exe and select OK.
The clipboard should work afterwards.
I found out that on Linux guests (Ubuntu in my case) and Windows 7 hosts (I guess that doesn't matter) you just have to restart the following process on your guest machine:
/usr/bin/VBoxClient --clipboard
Find out the PID of the process with ps and kill it. Afterwards start the process with the above command again and the clipboard starts working again. I use this for example:
kill $(ps aux | grep '/usr/bin/VBoxClient --clipboard' | grep -v grep | awk '{print $2}')
/usr/bin/VBoxClient --clipboard
Try running vboxadd-timesyn start
to restart the service.
One other thing that I remember reading was to change the clipboard sharing from bidirectional to host to guest.
Here you can find an old bug ticket that looks similar to your problem. It's a long read, but you may find some suggestions in there useful.
Finally, if nothing solves the problem, I suggest you to open a bug report in VirtualBox's Bugtracker yourself, because you are not the first one having problems with the shared clipboard.