Ani
Ani

Reputation: 113462

Unable to perform actions on UNC path / network drive

I'm trying to create an installer with WiX that has a step that writes to a network drive via a UNC path, but no matter what I do, I run into the error "Could not access network location":

enter image description here

The network location in question exists and is accessible to the installer process.

Here's what I've tried:

<SetDirectory Action="SetInstallDir" Id="INSTALLFOLDER" Value="\\tsclient\Z\VMSharedFolder\Docs">INSTALLFOLDER=""</SetDirectory>
msiexec /i Wixv3.msi INSTALLFOLDER="\\tsclient\Z\VMSharedFolder"
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFiles64Folder">
    <Directory Id="INSTALLFOLDER" Name="WixV3">
      <Component Id="test" Guid="95AB91F2-7DFE-4D1C-8114-BF1D07AD440C" Win64="yes" >
        <File Id="test.txt" Source="Files\test.txt" KeyPath="yes" Checksum="no"/>
      </Component>
    </Directory>
  </Directory>

  <Directory Id="MYPERSONALFOLDER" Name="WillBeReplaced"/>
</Directory>

<SetDirectory Action="SetInstallDir" Id="MYPERSONALFOLDER" Value="\\tsclient\Z\VMSharedFolder\Docs">MYPERSONALFOLDER=""</SetDirectory>
msiexec /i Wixv3.msi WIXUI_DONTVALIDATEPATH="1"  
<Property Id="WIXUI_DONTVALIDATEPATH" Value="1" />
<Directory Id="PersonalFolder" Name="UserHomeDocuments"/>
<StandardDirectory Id="PersonalFolder" />

But none of the above solutions worked; they all fail with the same error message as above. Which leads me to conclude that WiX or MSI installers in general have a problem with UNC paths / network drives in general. This leaves me all the more confused as this seems to be a supported scenario (from searching on the internet).

Could anyone tell me what's actually going on here and what the underlying problem is? As I mention above, I can't avoid the need to write to a network drive as we have a use-case for that.

Upvotes: 1

Views: 153

Answers (1)

Nikolay
Nikolay

Reputation: 12245

Installing files to a network drive is not a supported scenario, because the installer installs files under a special local system account that does not have access to the network (for security reasons). Also, your mapped drive exists in the logged-in user context only, as far as I understand.

It does not matter under which user you start the installer, and that the user has access to that location; the installer will switch to "system" context when installing files. The terminal server drive is mounted for the current user, so it will simply "missing" in the system context. Check out the "two-phases" installation for MSI. On the first pass, a script of required actions is generated (in user context); on the second pass, this script is executed (in system context)

If you want to copy some file under the current user account, you can, but you may need to do that explicitly using a custom action that should run in the current user context (i.e. to have "Elevated" set to "no"). Depending on your requirements, you could also try to enable network drive access for the local system installer service; but that may require doing it on all computers where you plan to install your app, and could be a security breach.

Upvotes: 0

Related Questions