在没有 'net use' 的 windows-host 上从 windows-box 访问共享的 vagrant-folder

Access shared vagrant-folder from windows-box on windows-host without 'net use'

从虚拟机 (Windows Server 2016 Core),我无法访问共享文件夹 C:\Vagrant(符号链接到 \vboxsrv\vagrant,默认对于 vagrant 的 VirtualBox-provider),无需首先将其附加为网络驱动器。 我什至不必通过网络驱动器访问它,附加它就足够了...

显示行为的虚拟机控制台:

C:\>dir
 Volume in drive C is Windows 2016
 Volume Serial Number is 9814-DDEB

 Directory of C:\

04/05/2018  02:09 PM    <DIR>          inetpub
04/05/2018  01:33 PM    <DIR>          Logs
07/16/2016  01:18 PM    <DIR>          PerfLogs
04/05/2018  02:18 PM    <DIR>          Program Files
04/05/2018  02:17 PM    <DIR>          Program Files (x86)
04/05/2018  02:07 PM    <DIR>          Scripts
07/24/2018  08:21 AM    <DIR>          Users
07/24/2018  08:20 AM    <SYMLINKD>     vagrant [\vboxsrv\vagrant]
07/24/2018  08:21 AM    <DIR>          Windows
               0 File(s)              0 bytes
               9 Dir(s)  30,747,582,464 bytes free

C:\>cd Vagrant
The system cannot find the path specified.

C:\>cd vagrant
The system cannot find the path specified.

C:\>net use X: \vboxsrv\vagrant
The command completed successfully.


C:\>cd vagrant

C:\vagrant>    LOL  <------------------------

流浪者文件如下所示:

Vagrant.configure("2") do |config|
    config.vm.box = "ajourtestserver"
    config.vm.box_url = "file:///u:/TestImage/ajourtestserver.json"
    config.vm.box_check_update = true
    config.vm.provider "virtualbox" do |vb|
        vb.memory = 4096
        vb.cpus = 4
    end 
end

谁能解释一下这是怎么回事?这对我来说似乎很奇怪...

我从未找到解释,但添加 "net use" 语句作为内联 shell 配置似乎是一个可靠的解决方法。对于遇到此问题的任何其他人,这里是我的解决方法的一些详细信息。

以下内容已添加到 VagrantFile:

config.vm.provision "symlink-fix", type: "shell" do |s|
    s.inline = "net use X: \vboxsrv\vagrant"
end

语句实际失败:

==> default: Running provisioner: symlink-fix (shell)...
    default: Running: inline PowerShell script
==> default: System error 67 has occurred.
==> default: The network name cannot be found.

...所以没有添加 'X:' 网络驱动器 - 但现在可以访问 C:\Vagrant 文件夹¯\_(ツ)_/¯