单击Gnu / Linux主机中的文件,以在VirtualBox的MS-Windows guest虚拟机中安装的应用程序打开

用户399146

我希望能够在Oracle VirtualBox的Windows guest虚拟机中安装的应用程序中的Linux主机中(双击)打开文件。

详细信息:我在Linux主机的〜/ Documents文件夹中有myfile.docx,并且MS Word应用程序安装了Windows来宾OS。目录〜/ Documents也以完全读写访问权限安装在Windows guest虚拟机的Y:\路径下。我还设置了Windows guest虚拟机,使其与Linux主机(在VBox中非常吸引人的一部分)以无缝模式工作。

现在,一旦我启动Windows guest虚拟机,我就不再理会它了。我只想双击Linux主机中的myfile.docx,以便在MS Word中打开,仅此而已!(不要理会这个MS Word的来源)。

实际上,作为第一步,我在Linux主机终端中使用以下命令打开myfile.docx取得了部分成功:

VBoxManage guestcontrol "Win07" run --exe "C:\\Program Files (x86)\\Microsoft Office\root\\Office16\\WINWORD.EXE" --username sbnwl --password myPassword -- WINWORD/arg0 "Y:\myfile.docx"

该文件立即在MS Word中打开。完美的!请注意,上述命令末尾的参数(“ Y:\ myfile.docx”)需要Windows样式的绝对路径。

现在,我尝试在〜/ .local / shrare / applications路径中制作具有以下内容的桌面配置文件:

[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 -- WINWORD/arg0 HOW-TO-SUPPLY-WINDOWS-STYLE-PATH-TO-THE-FILE-BEING-DOUBLE-CLICKED? 
Name[en]=Word
Icon=/usr/share/icons/word.png

有人知道如何在盯着Exec =的行的末尾完成此参数吗?

用户399146

感谢所有在这里看过并发表评论的人...

可以通过来宾应用程序单击打开主机文件。现在,使用virtualbox在Linux主机上提供绝佳的体验

这是完整的解决方案!

步骤总结如下:

步骤1->确保满足以下要求:

  1. 要打开的文件位于主机LINUX文件系统上(也支持子目录)
  2. 主机的文档目录以Y:\的形式安装在WINDOWS GUEST中(最好具有写权限)
  3. WINDOWS GUEST中主机的下载目录以Z:\装载(最好具有写权限)
  4. 主机的$ HOME目录作为X:\安装在WINDOWS GUEST中(最好具有只读权限)

步骤2->您需要在$ HOME / .local / share / applications路径中创建一个名为'Word.desktop'的桌面条目文件(不带引号),并包含以下内容:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=Word 365
NoDsiplay=true
Exec=$HOME/.local/share/applications/muScripts/runWord %u
Name[en]=Word 365 ProPlus
Icon=/usr/share/icons/MSWord.png

在上面的$ HOME中,用userpath代替,例如/ home / user

第3步->制作一个名为'runWord'的可执行文件(不带引号),并将以下内容放入目录$ HOME / .local / share / applications / muScripts /

#!/bin/bash

# THIS PROGRAM (runWord) OPENS *.docx FILES ON LINUX HOST, WITH MS Word APPLICATION
# INSTALLED ON A WINDOWS GUEST (IN VirtualBox).

## STEP1--> CHECK FOLLOWING REQUIREMENTS ARE MET:
# 1. THE FILES ARE EITHER IN Documents OR Downloads OR any other DIRECTORY/SUB-DIRECTORY 
#    OF THE HOST FILESYSTEM (SUB-DIRECTORIES also supported)
# 2. THE host's Documents DIRECTORY IS MOUNTED AS Y:\ IN THE WINDOWS GUEST (preferably with write permissions)
# 3. THE host's Downloads DIRECTORY IS MOUNTED AS Z:\ IN THE WINDOWS GUEST (preferably with write permissions)
# 4. THE host's     $HOME directory IS MOUNTED AS X:\ IN THE WINDOWS GUEST (prefer with read-only permissions)

## STEP2--> YOU NEED TO CREATE A DESKTOP ENTRY FILE WITH FOLLOWING CONTENTS, IN THE
# $HOME/.local/share/applications PATH:
#
#[Desktop Entry]
#Version=1.0
#Encoding=UTF-8
#Type=Application
#Name=Word 365
#NoDsiplay=true
#Exec=/home/hostuser/.local/share/applications/muScripts/runWord %u
#Name[en]=Word 365 ProPlus
#Icon=/usr/share/icons/MSWord.png
#

## STEP3--> PLACE THIS FILE IN THE DIRECTORY $HOME/.local/share/applications/muScripts/

#
##--CODE DEVELOPERS/CONTRIBUTORS -- andpy73, sbnwl
##-- andpy73 https://forums.virtualbox.org/memberlist.php?mode=viewprofile&u=50134
##-- sbnwl https://forums.virtualbox.org/memberlist.php?mode=viewprofile&u=116543
##-- Original post at https://forums.virtualbox.org/viewtopic.php?f=7&t=91799
#

clear

#
# Check that we have got the correct number of parameters.
#
if [ "$#" -ne 1 ]; then
   echo "Warning: Remote script requires one parameter to be passed!"
#   exit
fi

#
# Check if the file exists in the host file system incase we are
# called from a terminal.
#
if [ ! -f "$1" ]; then
   echo "Warning: File not found in the host file system!"
   echo '         Make sure the file' $1 'exists!'
#   exit
fi

#
# Get the filename part from the full path given.
#
FILE=$(basename "$1")
nixPATH=$(dirname "$1")
echo 'Full UNIX path is:' $nixPATH

echo 'Opening' $FILE ' ...'
echo 'Full UNIX path of the file is:' $1

#
# Make a new executable file having WINDOWS_PATH as argument at the end of 
# VBoxManage command and write the command sting in it.
#
mkdir ~/.tmp
cd ~/.tmp
rm tmpfile
touch tmpfile
chmod +x tmpfile
printf 'VBoxManage guestcontrol "Win10" run --exe "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE" --username myWindowsUsername --password myWindowsPassword -- WINWORD/arg0 ' >> tmpfile

if [[ $1 == "$HOME/Documents/"* ]]; then
   echo "The file is in Documents folder, i.e., in Y:\ of Windows host!"
   prefix="$HOME/Documents"
   partPATH=${nixPATH#"$prefix"}
   echo 'Partial UNIX path is:' $partPATH
   winPATH=${partPATH//\//\\}
   echo 'Partial WINDOWS path is:' $winPATH
   echo 'Full WINDOWS path is:' '"'Y:\\$partPATH\\$FILE'"'
   echo '"'Y:\\$partPATH\\$FILE'"' >> tmpfile

elif [[ $1 == "$HOME/Downloads/"* ]]; then
   echo "The file is in Downloads folder, i.e., in Z:\ of Windows host!"
   prefix="$HOME/Downloads"
   partPATH=${nixPATH#"$prefix"}
   echo 'Partial UNIX path is:' $partPATH
   winPATH=${partPATH//\//\\}
   echo 'Partial WINDOWS path is:' $winPATH
   echo 'Full WINDOWS path is:' '"'Z:\\$partPATH\\$FILE'"'
   echo '"'Z:\\$partPATH\\$FILE'"' >> tmpfile

else
   echo "The file is elsewhere, i.e., in X:\ of Windows host! (If $HOME is mounted as X:\)"
   prefix="$HOME"
   partPATH=${nixPATH#"$prefix"}
   echo 'Partial UNIX path is:' $partPATH
   winPATH=${partPATH//\//\\}
   echo 'Partial WINDOWS path is:' $winPATH
   echo 'Full WINDOWS path is:' '"'X:\\$partPATH\\$FILE'"'
   echo '"'X:\\$partPATH\\$FILE'"' >> tmpfile
fi

#
# Show the contents of tmpfile (for only debugging purpose)
#
echo '-------------------------------------------------------------------------'
echo 'This is the content of tmpfile for debugging purpose:'
echo ' '
cat tmpfile
echo ' '
echo '-------------------------------------------------------------------------'

#
# Run the commands in tmpfile for opening the double-clicked file!
#
./tmpfile &
rm tmpfile

请确保您在上面的脚本文件中以printf'VBoxManage guestcontrol开头的特定行中进行了以下更改

  1. 将字符串Win10替换为安装了MS Office的Windows Guest虚拟机的名称
  2. 在Windows Guest OS上将myWindowsUsername替换为您的登录用户名
  3. 在Windows Guest OS上将myWindowsPassword替换为您的登录密码

步骤4->将宿主文件系统中的* .docx和.doc文件与程序“ Word”相关联。此处的操作如下:1.转到Linux主机文件管理器中的任何文件MS Word文件( .docx)(例如nautilus,nemo,dolphin等)2.右键单击* .docx文件,然后单击“属性”。将会弹出一个窗口。3.单击“打开方式”选项卡,然后在可用应用程序列表中滚动。选择“ Word 365 ProPlus”,然后单击窗口右下角的“设置为默认值”。

就这样!

下次只需在virtualbox中以无缝模式启动Windows计算机(登录后按CTRL + L),然后再进行操作即可。

您需要做的就是直接在Linux文件管理器中双击* .docx文件。

和Voila,它们将立即在MS Word应用程序中打开。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何从Windows主机启动VirtualBox Linux guest虚拟机中的脚本?

来自分类Dev

当Windows的bootmanager位于其他驱动器上时,从VirtualBox中的Linux主机引导Windows guest虚拟机

来自分类Dev

如何在Windows 7虚拟机中安装程序?

来自分类Dev

Linux主机中的重新映射键(带有xmodmap)在VirtualBox Windows guest虚拟机中停止工作

来自分类Dev

Vagrant无法使用Windows 7上的VirtualBox Guest Additions在Linux guest虚拟机中挂载

来自分类Dev

Vagrant无法通过Windows 7上的VirtualBox Guest Additions在Linux guest虚拟机中挂载

来自分类Dev

在Kubuntu的Windows guest虚拟机中无法识别iPod

来自分类Dev

在Kubuntu的Windows guest虚拟机中无法识别iPod

来自分类Dev

如何在Windows 10主机上的Ubuntu 16 Virtual Box guest虚拟机中安装PHP5?

来自分类Dev

如何分析在KVM guest虚拟机中运行的应用程序

来自分类Dev

无法从Mac主机ping虚拟框中的Windows guest虚拟机

来自分类Dev

VirtualBox:从Linux guest虚拟机访问Windows主机的命令提示符

来自分类Dev

获取Windows 8主机以访问Windows Server guest虚拟机中托管的网站

来自分类Dev

从任务计划程序打开和关闭 windows10 中的虚拟机

来自分类Dev

我是否需要在Windows 10 guest虚拟机中安装QEMU Agent和SPICE Agent?

来自分类Dev

如何使用Windows guest虚拟机在VirtualBox中获得真正的全屏显示?

来自分类Dev

在64位OSX主机上安装32位Windows 7 Guest虚拟机

来自分类Dev

在Linux主机和Windows guest虚拟机之间共享文件夹

来自分类Dev

如何在virtualbox guest虚拟机中安装xorg?

来自分类Dev

Windows 8.1 guest虚拟机,Linux主机vmware工作站12的“安装vmware工具”显示为灰色

来自分类Dev

Ubuntu主机无法Ping Guest虚拟机Windows 10

来自分类Dev

在Windows 7中将Ubuntu 32位安装为虚拟机(VirtualBox)-问题

来自分类Dev

在Windows Azure虚拟机VM上安装FTP应用程序FileZilla Server

来自分类Dev

如何从Ubuntu VirtualBox guest虚拟机复制粘贴到Windows主机?

来自分类Dev

如何从Ubuntu VirtualBox guest虚拟机复制粘贴到Windows主机?

来自分类Dev

在Ubuntu主机上激活Windows 10 Home VirtualBox guest虚拟机的OEM许可证

来自分类Dev

音频在VirtualBox Windows 10 guest虚拟机(macOS主机)上不起作用

来自分类Dev

使用Samba从Linux来宾与VirtualBox中的Windows主机共享文件夹

来自分类Dev

如何在VMware Fusion 5,Windows 8 guest虚拟机中退出全屏模式?

Related 相关文章

  1. 1

    如何从Windows主机启动VirtualBox Linux guest虚拟机中的脚本?

  2. 2

    当Windows的bootmanager位于其他驱动器上时,从VirtualBox中的Linux主机引导Windows guest虚拟机

  3. 3

    如何在Windows 7虚拟机中安装程序?

  4. 4

    Linux主机中的重新映射键(带有xmodmap)在VirtualBox Windows guest虚拟机中停止工作

  5. 5

    Vagrant无法使用Windows 7上的VirtualBox Guest Additions在Linux guest虚拟机中挂载

  6. 6

    Vagrant无法通过Windows 7上的VirtualBox Guest Additions在Linux guest虚拟机中挂载

  7. 7

    在Kubuntu的Windows guest虚拟机中无法识别iPod

  8. 8

    在Kubuntu的Windows guest虚拟机中无法识别iPod

  9. 9

    如何在Windows 10主机上的Ubuntu 16 Virtual Box guest虚拟机中安装PHP5?

  10. 10

    如何分析在KVM guest虚拟机中运行的应用程序

  11. 11

    无法从Mac主机ping虚拟框中的Windows guest虚拟机

  12. 12

    VirtualBox:从Linux guest虚拟机访问Windows主机的命令提示符

  13. 13

    获取Windows 8主机以访问Windows Server guest虚拟机中托管的网站

  14. 14

    从任务计划程序打开和关闭 windows10 中的虚拟机

  15. 15

    我是否需要在Windows 10 guest虚拟机中安装QEMU Agent和SPICE Agent?

  16. 16

    如何使用Windows guest虚拟机在VirtualBox中获得真正的全屏显示?

  17. 17

    在64位OSX主机上安装32位Windows 7 Guest虚拟机

  18. 18

    在Linux主机和Windows guest虚拟机之间共享文件夹

  19. 19

    如何在virtualbox guest虚拟机中安装xorg?

  20. 20

    Windows 8.1 guest虚拟机,Linux主机vmware工作站12的“安装vmware工具”显示为灰色

  21. 21

    Ubuntu主机无法Ping Guest虚拟机Windows 10

  22. 22

    在Windows 7中将Ubuntu 32位安装为虚拟机(VirtualBox)-问题

  23. 23

    在Windows Azure虚拟机VM上安装FTP应用程序FileZilla Server

  24. 24

    如何从Ubuntu VirtualBox guest虚拟机复制粘贴到Windows主机?

  25. 25

    如何从Ubuntu VirtualBox guest虚拟机复制粘贴到Windows主机?

  26. 26

    在Ubuntu主机上激活Windows 10 Home VirtualBox guest虚拟机的OEM许可证

  27. 27

    音频在VirtualBox Windows 10 guest虚拟机(macOS主机)上不起作用

  28. 28

    使用Samba从Linux来宾与VirtualBox中的Windows主机共享文件夹

  29. 29

    如何在VMware Fusion 5,Windows 8 guest虚拟机中退出全屏模式?

热门标签

归档