Open files in linux file manager (with double click) using host application

Discussions related to using VirtualBox on Linux hosts.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Open files in linux file manager (with double click) using host application

Post by sbnwl »

Hi all,
This is my first post.
I have made a desktop entry file named "Word.desktop" and saved it in the path ~/.local/share/applications with the following content:

Code: Select all

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=word
NoDsiplay=true
Exec=VBoxManage guestcontrol "Win07" run --exe "C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE" --username sbnwl --password myPassword
Name[en]=Word
Icon=/usr/share/icons/word.png
Afterwards, I have also associated all *.docx files to open with Word.desktop in nautilus.
I am running a the windows guest (named Win07) in the Ubuntu host.

Now whenever I double click a word file in host file manager (here nautilus), for example mydoc.docx, the application Microsoft Word launches perfectly (in Win07) but it does not load the file mydoc.docx which is my intention. Instead, it opens a blank word document.

Can anyone suggest what is the proper command to be able to open mydoc.docx?
Or how to pass the file being double-clicked as argument the VBoxManage command?

Thank you in advance...
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open files in linux file manager (with double click) using host application

Post by socratis »

The .docx file resides on your host. The Word application resides on the guest. There are no such provisions in VirtualBox where you could use guest applications to open host documents. Unless they reside in a shared folder or a networked one...
sbnwl wrote:Or how to pass the file being double-clicked as argument the VBoxManage command?
From the User Manual 8.2. Commands Overview, or the "VBoxManage guestcontrol" (no arguments) command output:
VBoxManage guestcontrol <uuid|vmname> [--verbose|-v] [--quiet|-q]
                        [--username <name>] [--domain <domain>]
                        [--passwordfile <file> | --password <password>]
...
                        run [common-options]
                        [--exe <path to executable>] [--timeout <msec>]
                        [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
                        [--ignore-operhaned-processes] [--profile]
                        [--no-wait-stdout|--wait-stdout]
                        [--no-wait-stderr|--wait-stderr]
                        [--dos2unix] [--unix2dos]
                        -- <program/arg0> [argument1] ... [argumentN]]
More details in the User Manual, ch. 8.35 VBoxManage guestcontrol.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Re: Open files in linux file manager (with double click) using host application

Post by sbnwl »

@socratis
Thank you for your quick response.

The *.docx file in question is in the Documents folder of linux host and this folder is shared with write access to the Windows guest. So this is not the concern.

Also, before posting my problem, I had already spent my time through the documentation section of the Virtualbox that you linked in your post.

But still I am not able to figure it out how to do this...
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open files in linux file manager (with double click) using host application

Post by socratis »

sbnwl wrote:I had already spent my time through the documentation section of the Virtualbox that you linked in your post.
So, what did you try? Which arguments did you try to pass? What failed?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Re: Open files in linux file manager (with double click) using host application

Post by sbnwl »

So far I have tried the following command in the terminal first:

Code: Select all

VBoxManage guestcontrol "Win07" run --exe "C:\\Program Files (x86)\\Microsoft Office\root\\Office16\\WINWORD.EXE" --username sbnwl --password myPassword -- WINWORD/arg0 "Y:\myfile.docx"
And this correctly opens the file. This also means the last argument (Y:\myfile.docx) has to be in the form of Windows identifiable path format. The host path ~/Documents is mapped in the Windows guest as Y:\ and myfile.docx exists in ~/Documents host path.

The problem arises when I want to put the above command in *.desktop file after saving which it does not launch Microsoft Word when I double click myfile.docx in the host OS.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open files in linux file manager (with double click) using host application

Post by socratis »

sbnwl wrote:The problem arises when I want to put the above command in *.desktop file after saving
I have no clue what that sentence means.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: Open files in linux file manager (with double click) using host application

Post by andyp73 »

A .desktop file is used in Gnome typically to define an icon on the desktop that is used to start an application. I think the OP is also trying to use it as an association within the Linux file manager so that double clicking on a .docx opens the file in Word on within the guest. I don't know whether they have that capability or whether they only create shortcut icons.

I would have thought that doing it though a bash script would be easier.

-Andy.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open files in linux file manager (with double click) using host application

Post by socratis »

Then it becomes a Gnome issue, on how to properly format/escape the correct associated files. Not really a VirtualBox issue. Since we've seen that the VBoxManage command works as expected, then it's a Gnome issue....
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Re: Open files in linux file manager (with double click) using host application

Post by sbnwl »

@socratis

I think it is neither a gnome issue nor a VirtualBox issue. The only problem is how to be able to supply the "Windows guest syntax path" of myfile.docx towards the end of virtualbox command as arguement? See below.

Code: Select all

VBoxManage guestcontrol "Win07" run --exe "C:\\Program Files (x86)\\Microsoft Office\root\\Office16\\WINWORD.EXE" --username sbnwl --password myPassword -- WINWORD/arg0 HOW-TO-SUPPLY-WINDOWS-STYLE-PATH-TO-THE-FILE-BEING-DOUBLE-CLICKED? 
@andyp73
Yes, it might require a bit of bash shell commands.

And for this:
I think the OP is also trying to use it as an association within the Linux file manager so that double clicking on a .docx opens the file in Word
I know, Crossover Linux does have and uses *.desktop files to open a *.docx file in Linux. The only different part here is that the application MSWord is isntalled in the Windows guest and then it is being called by running the VBoxManage command in the host shell.

I am pretty sure it is doable and it will open a lot of degree of freedom for those who use MSOffice to directly manage their documents in Linux hosts without bothering/knowing where the MSOffice application resides.

Please come on and share your time. This is another very attractive and strong point of VBOX...
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: Open files in linux file manager (with double click) using host application

Post by andyp73 »

Desktop Entry Specification may be your friend.

-Andy.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Re: Open files in linux file manager (with double click) using host application

Post by sbnwl »

@andpy73

You may be right..

Let's hope someone with desktop specification expertise could bump in and help...

I will also continue to try, meanwhile..
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open files in linux file manager (with double click) using host application

Post by socratis »

sbnwl wrote:The only problem is how to be able to supply the "Windows guest syntax path" of myfile.docx towards the end of virtualbox command as arguement?
I believe that you've already answered that question yourself:
sbnwl wrote:
VBoxManage guestcontrol "Win07" run
     --exe "C:\\Program Files (x86)\\Microsoft Office\root\\Office16\\WINWORD.EXE"
     --username sbnwl
     --password myPassword
     -- WINWORD/arg0 "Y:\myfile.docx"
How you translate that into a shortcut is another question.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Re: Open files in linux file manager (with double click) using host application

Post by sbnwl »

@socratis
I believe that you've already answered that question yourself:
True, to some extent.
But I am looking for a solution. I know we are close to the solution.
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: Open files in linux file manager (with double click) using host application

Post by andyp73 »

Did you read the details on the Exec entry in the Desktop Entry Specification that I linked to:
Desktop Entry Specification wrote:%f - A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax
To me that says substitute your hardcoded document filename and replace it with %f.

-Andy.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
sbnwl
Posts: 11
Joined: 13. Feb 2019, 07:52

Re: Open files in linux file manager (with double click) using host application

Post by sbnwl »

@andy73

I already tried putting %f and %u one by one in the end replacing the actual file path (Y:\myfile.docx) but nothing happens.

I am sure the application MS Word is not able to directly pickup the absolute Linux syntax path (~/Documents/my file.docx) which is supplied by the %f argument.

We need a sort of piece of code that translates first the Linux path (since file is clicked in Linux) into Windows equivalent and then supply it to %f of the Exec= command.

Or, is there another route to handle this problem ?
Post Reply