1

Packaging Tool Used: WIX.

Custom Actions are written in C++.

During installation my MSI creates a folder "X" inside ProgramData , by the end of installation i need to give folder share access to current logged in user (or any local user in the PC this input will be provided by the user during installation ) , I am unable to find any WIX element or a C++ API that could help me with this.

I figured out using element in wix i can provide permission to the folder(Security tab of folder attributes) , but i couldnt find a Wix element/C++ API to give share permissions.(Sharing tab of file attributes) Right now if u see "Everyone" has read access , Via my MSI i should be able to provide any user full access(Full control) in Sharing.

enter image description here

Saanvi
  • 43
  • 4

1 Answers1

3

WiX has features for this in their Util extension:

Documentation:

There are many further WiX special features in the Util dll: https://wixtoolset.org/documentation/manual/v3/xsd/util/

A concrete, mock-up example:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*" Name="WixFolderShare" Language="1033" Version="1.0.0.0" Manufacturer="Someone" UpgradeCode="b3d89acb-71d9-48ab-a3df-886d49965ea3">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"  />
    <MediaTemplate EmbedCab="yes" />
        
    <!--<UIRef Id="WixUI_Mondo" />--> <!-- Diabled main GUI -->
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <Feature Id="ProductFeature" Title="WixFolderShare" Level="1" />
    
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="Test Folder">

          <Component Feature="ProductFeature">

            <File Source="$(env.SystemRoot)\notepad.exe" />

            <util:User Id="Everyone" Name="Everyone" />

            <!-- Create Share with share permissions -->
            <util:FileShare Id="TestShare" Name="TestShareName" Description="This is a test share.">
              <util:FileSharePermission User="Everyone" GenericAll="yes"/>
            </util:FileShare>

            <!-- NTFS ACL permissions -->
            <CreateFolder>
              <util:PermissionEx User="Everyone" GenericAll="yes" />
            </CreateFolder>

          </Component>

      </Directory>
      </Directory>
    </Directory>

</Product>
</Wix>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • I see that the articles and the code talk about file sharing.. Is there any way for folder sharing similarly? What is the tag? – Saanvi Sep 26 '20 at 12:19
  • Try to install that sample and check if the folder involved is shared. You can do so by hitting `Windows Button` + Tap `R`. Now type `"fsmgmt.msc"` and press Enter. Check "Shared Folders". [Snap-ins list](https://serverfault.com/a/158088/20599). – Stein Åsmul Sep 26 '20 at 13:10