如何在windows vm上运行gui应用程序?

时间:2016-08-22 10:57:59

标签: vagrant vagrant-windows vagrant-plugin

我在Mac上安装了vagrant和virtual box。我创建了一个Windows10虚拟机,并配置了winrm。

我可以通过vagrant在Windows VM上运行命令。但是我无法在VM上看到任何GUI。

例如,如果我在Windows VM中打开命令提示符并发出命令"启动chrome.exe",则启动chrome浏览器并显示浏览器ui。但是,如果我通过winrm vagrant winrm -c "start chrome.exe"键入相同的命令,它会启动浏览器,但是ui不会显示在VM中。如果我通过shell配置程序运行命令,则会出现问题。

有什么办法,我可以从vagrant运行命令,应用程序将在VM中以GUI模式启动吗?

3 个答案:

答案 0 :(得分:2)

  

有什么办法,我可以从vagrant运行命令,应用程序将在VM中以GUI模式启动吗?

没有

来自https://msdn.microsoft.com/en-us/library/aa384426(v=vs.85).aspx

  

您可以使用WinRM脚本对象,WinRM命令行工具或Windows Remote Shell命令行工具WinRS从本地和远程计算机获取管理数据......

winrm用于远程管理并且不转发X窗口,因此不能启动像chrome这样的程序并将UI转发到其他地方。

从VM运行UI程序的最佳选择:

  • 从VM GUI运行(通过从Vagrantfile启用或从VirtualBox打开VM)
  • 正在运行vagrant rdp以登录虚拟机

答案 1 :(得分:0)

最简单的方法是以“ GUI模式”(而不是“无头”)运行VM。 我使用Oracle的VirtualBox,这是从Vagrantfile内轻松配置的选项之一。

查看我的“提供商特定的配置”部分:

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
   config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #        # (so we can run the browser)
     vb.gui = true
     vb.name = "windows10-eval"
  #   # Customize the amount of memory on the VM:
     vb.memory = "2048"
   end

当我的VM启动时,我会自动获得一个GUI,该GUI看起来就像是在引导常规Windows计算机一样。此盒带有已配置的chrome,很方便,但是安装和使用起来很容易。

答案 2 :(得分:0)

尽管您不能直接从WinRM运行GUI应用程序,但是也可以在Windows启动中添加指向应用程序的链接,以确保应用程序在系统启动时运行。

在配置脚本中添加以下内容:

mklink C:\Users\vagrant\AppData\Roaming\Microsoft\Windows\"Start Menu"\Programs\Startup\MyApp.link C:\MyApp\\MyApp.exe
shutdown /r /t 1
相关问题