Script to open .docx files from linux (eOS) file manager

Discussions related to using VirtualBox on Linux hosts.
Post Reply
EduWanKenobi
Posts: 1
Joined: 4. Sep 2017, 11:39

Script to open .docx files from linux (eOS) file manager

Post by EduWanKenobi »

Hi.
I've created a script on my eOS machine to open word 2016 in my Win7 VM, then a .desktop file to open this script from my launcher and make it appear in the "open with" contextual menu thanks to the %U option.
Now I want to open the file that has been cliked on directly on Word 2016 inside my VM.
I created a shared folder in the guest machine wihich points to my hosts "/media" folder, where all my work files are located

I guess the %U parameter in the "exec" line of my desktop file passes the Linux file location path.
I can click a .docx file in my file manager, then word 2016 opens but it doesn't open the file as I guess Word 2016 doesn't receive the correct path.
Feel free to correct any of the statements above

I have 2 questions, to make word open the wanted file, do I have to pass the parameter through my .sh file or does it pass through my desktop file?
How can I edit the file location string sent by %U to get adapted to the shared folder correct path.
I hope my question is understandable...

.sh file

Code: Select all

#!/bin/bash
if [ $( VBoxManage list runningvms | wc -l ) != "0" ]
then
VBoxManage guestcontrol Windows7 run C:\\Program\ Files\\Microsoft\ Office\\Office16\\WINWORD.EXE --username ******* --password ******
VBoxManage controlvm "Windows7" savestate
else
VBoxManage startvm "Windows7" && VBoxManage guestcontrol Windows7 run C:\\Program\ Files\\Microsoft\ Office\\Office16\\WINWORD.EXE  --username ******* --password ****** 
VBoxManage controlvm "Windows7" savestate
fi
.Desktop file

Code: Select all

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
MimeType=application/vnd.openxmlformats-officedocument.wordprocessingml.document
Terminal=false
Icon[en_US]=/usr/share/icons/ePapirus/64x64/apps/ms-word.svg
Name[en_US]=Word 2016
Exec=/home/*******/bin/vbword.sh %U
Comment[en_US]=MS Word 2016 through VirtualBox
THX for your answers!!
Post Reply