It would be AWESOME to double-click a file on host then open in guest's app

Here you can provide suggestions on how to improve the product, website, etc.
Post Reply
BJ6hello
Posts: 4
Joined: 6. Nov 2019, 14:20

It would be AWESOME to double-click a file on host then open in guest's app

Post by BJ6hello »

This is VERY VERY USEFUL to users who use Linux or Mac OS on host.

We wish a way to associate some MIME or suffix of file to an application installed in VM (usually Windows guest, for some Windows-only software).

I know this need filesystem work to automatically make the file accessable for guest, and automatically sync to host when save.
Last edited by mpack on 21. Aug 2020, 11:15, edited 1 time in total.
Reason: Remove unnecessary markup.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by mpack »

A VM is just a second PC, so anything you could do with two physical PCs you can still do when one or both PCs is virtual.

p.s. I removed your markup that doubled the size of your text. There's no need to shout.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by scottgus1 »

Based on Mpack's statement above (The host and Virtualbox guest behave as two separate PCs), here's how this process could work in Virtualbox, and how you could do it yourself now with your own scripts (Guest Additions are required, see 'vboxmanage/vboxcontrol guestproperty get/set'):
  1. You double-click/right-click-Open-With a host file.
  2. The Open/Open-With command chosen is set by the Registry/whatever-Linux-or-Mac-uses-for-a-registry to start a custom host script/program.
  3. The host script makes a temporary writable Guest Additions Shared Folder in the folder containing the opened file.
  4. The host script sets a guestproperty to communicate to the guest that a file is ready, the GASF path where the guest can locate the file, the file name, and perhaps what guest program to open the file with.
  5. The host script monitors for the clearing of the guestproperty.
  6. A guest script monitoring for that changed guestproperty copies the file from the GASF to the guest filesystem's temp folder. (GASFs are only for copying, not opening/editing/saving).
  7. The guest script opens the temp file with the desired program. The script may attempt to open or lock the original GASF file to keep the host from editing that file too. Maybe a temporary "lock indicator flag file" gets created in the GASF to let the user know the guest is still processing the file.
  8. The guest script monitors the guest program's lock on the temp file or the running of the guest program itself, waiting for the guest program to be finished with the temp file.
  9. The guest script copies the temp file back into the GASF, removing the lock flag file after the copy is complete.
  10. The guest script clears the guestproperty.
  11. The host script notices the cleared guestproperty, removes the GASF configuration, and perhaps causes a temporary popup to show that the process is complete.
Note that the host and guest scripts act as a pair, each watching for the other to complete. If you want to run this process multiple times simultaneously, then the host script launched by the Open/Open-With has to be a launcher that spawns a separate host script for each permutation of the "open on the guest" process, and the guest script waiting for guestproperties has to check a range of guestproperties, perhaps all guestproperties starting with "BJ6hellolaunch..." then spawn a separate guest script that communicates and acts on a particular guestproperty.

Additionally, if multiple runs of the scripts run off the same host folder, a flag of sorts must be set to keep the GASF in place until the last script instance is finished using it.
CKing123
Posts: 9
Joined: 18. Aug 2020, 05:47

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by CKing123 »

This is similar to a feature in Parallels Desktop (though in that case, Parallels Desktop shows all Windows programs on ~/Applications/Applications (Parallels)/{VM Name}/Windows program name.app

So, you can tell Finder to open a file under any of the applications that are installed in a Windows VM and it will open it. I presume it copies the file, opens it in the actual VM and after the app is done, copies it back as scottgus explains it
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by scottgus1 »

CKing123 wrote:This is similar to a feature in Parallels Desktop
Yes, that setup sounds similar to what BJ6hello wants. It's really all a matter of what extra programs are installed in the guest OS and some starters & listeners on the host OS. There may even be drivers that can let the guest OS see into the host's file system, or more completely-API'd shared folders that can allow open/edit/save. Even a service that can show the guest program's icon on the host's taskbar, which tells the 'seamless-style' guest OS to show the program when clicked.

It all depends on what the program designer was shooting for. Parallels seems to want Windows 'parallel' to Mac OS, whereas Virtualbox shoots for a 'virtual box' inside the physical box. :lol:

Regrettably, a sense of practicality must be inserted: :cry: Parallels & similar programs and Virtualbox have both existed for some years, and Virtualbox doesn't have this yet, extremely likely because Oracle's customers haven't asked for it yet. It'll need a user to contribute code to get this in Virtualbox. Community-rolled Extension Pack & Guest Additions 2?
BJ6hello
Posts: 4
Joined: 6. Nov 2019, 14:20

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by BJ6hello »

scottgus1 wrote:GASFs are only for copying, not opening/editing/saving
Thank you scottgus1 for replying and detailing the steps :)
Why not use symbolic link?
I've tried, for example, on Linux host

Code: Select all

ln -s /media/mydrive/myfile /tmp/gasf/myfile
then in Windows guest mount shared folder /tmp/gasf as Z:
Windows guest apps can directly edit and save files in Z:

Also I've tried soft-linking a Linux host's folder into GASF, works.
Even we could try setting / as GASF so it works like wine's Z:
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by scottgus1 »

BJ6hello wrote:Why not use symbolic link?
If it works for opening/editing/saving, it's an outside case, and long-term it's best to not rely on outside cases. The guest program could update and change how it accesses the file and go too far outside the GASF capabilities.
BJ6hello
Posts: 4
Joined: 6. Nov 2019, 14:20

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by BJ6hello »

Recently a new project github.com/Fmstrat/winapps was launched.
People like me who want this feature can have a look.
It's similar to what I expected
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: It would be AWESOME to double-click a file on host then open in guest's app

Post by scottgus1 »

BJ6hello wrote:github.com/Fmstrat/winapps
Appears to be based off KVM on Linux hosts, to run Windows apps in a Windows KVM guest, yet make them appear on the host, similar to Parallels mentioned above.

Of course, KVM != Virtualbox. Someone will probably have to contribute code to get this functionality into Virtualbox.
Post Reply