Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Create Application files and folders outside of VFS during MSIX install

Thu Feb 09, 2023 3:43 pm

Hi,

There are known scenario requirements when you need to migrate and package into an MSIX setup a classic Win32 app that needs to write user data/settings into a folder and or file located outside of the VFS folder.

For instance let's say you need to package into an MSIX setup a Win32 app that writes and reads some of its data from the following file:

Code: Select all

%PROGRAMDATA%\MyAppFolderOutsideVFS\MyAppSettings.config
Note the "MyAppSettings.config" file needs to be created outside of the VFS folder of the MSIX container, i.e. under this folder path:

Code: Select all

%PROGRAMDATA%\MyAppFolderOutsideVFS\
Now if you need the above folder and file path created during MSIX package installation, then all you need to do is just make sure you create the above folder path in "Files and Folders" view of your setup project and add the related file inside that folder. Just like this:
screenshot.jpg
screenshot.jpg (174.78KiB)Viewed 153022 times

And that is all. After MSIX installation, on application first run the above MyAppFolderOutsideVFS\MyAppSettings.config folder path and file will be created under %PROGRAMDATA% system folder.

Note: The above folder will not be created as long as there isn't at least one file included inside. If the folder is created as an empty folder in "Files and Folders" view, then it won't be created after MSIX installation.

Here it is attached a sample project created with Advanced Installer 20.3.1 that implements this scenario.
sampleProject.zip
(321.7KiB)Downloaded 996 times

Alternatively, as another solution approach for this scenario you can use our "PowerShell Scripts" support in "AppCompat" view. More exactly you can create a PowerShell script (e.g. createFileFolder.ps1) with the following code and execute it from your MSIX package:

Code: Select all

new-item $Env:PROGRAMDATA\MyAppFolderOutsideVFS -ItemType Directory
new-item $Env:PROGRAMDATA\MyAppFolderOutsideVFS\MyAppSettings.config
Here are the settings you should configure into your MSIX setup project:

1. create a new "Architect" project type and add an MSIX build in "Builds" view
screen1.jpg
screen1.jpg (84.74KiB)Viewed 153061 times
screen2.jpg
screen2.jpg (125.16KiB)Viewed 153061 times
2. go to "AppCompat" view and add a new "Start PowerShell Script" fix-up configured to run the above createFileFolder.ps1 script like this:
screen3.jpg
screen3.jpg (155.23KiB)Viewed 153061 times
3. build and run your setup project

Here it is attached a sample project created with Advanced Installer 20.3.1 that implements this scenario.
sample.zip
(862.58KiB)Downloaded 956 times
Hope this was useful for getting a starting point about how to take advantage of our PowerShell Scripts support in "AppCompat" view.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

kerenor
Posts: 11
Joined: Mon Mar 20, 2023 3:32 pm

Re: Create Application files and folders outside of VFS during MSIX install

Mon Mar 20, 2023 4:13 pm

Hi,
Thanks for this guide! Almost exactly what I needed :)

The one thing I need to do still is change permissions on C:\ProgramData\MyFolderOutsideVFS. I changed them in the permissions tab of the folder from the Advanced Installers "Files and Folders" screen, but they didn't pass on when installing (the folder just inherited the permissions of C:\ProgramData).
Trying to install as administrator somehow didn't create that folder at all :|

Would appreciate ideas on that
Thanks!

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Create Application files and folders outside of VFS during MSIX install

Tue Mar 21, 2023 3:26 pm

Hi and welcome to our forums,

This is possible using our "AppCompat" feature.

Just create a short PowerShell script that sets permissions on the related folder. For instance it sets Read&Execute permissions for "Everyone" user group. You can use the following code:

Code: Select all

$ACL = Get-ACL -Path "C:\ProgramData\MyAppFolderOutsideVFS"
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone","ReadAndExecute","Allow")
$ACL.SetAccessRule($AccessRule)
$ACL | Set-Acl -Path "C:\ProgramData\MyAppFolderOutsideVFS"

Then just go to "AppCompat" view of your setup project and add the above .ps1 script as a "Start PowerShell Script".
screen.jpg
screen.jpg (108.77KiB)Viewed 130135 times
Attached you can find a sample project created with Advanced Installer 20.4.1 implementing this scenario.
sampleProject.zip
(9.04KiB)Downloaded 715 times
All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube


Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Create Application files and folders outside of VFS during MSIX install

Wed Mar 22, 2023 4:30 pm

You are always welcome!

Glad my colleague Daniel was able to assist!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

kerenor
Posts: 11
Joined: Mon Mar 20, 2023 3:32 pm

Re: Create Application files and folders outside of VFS during MSIX install

Sun Aug 20, 2023 1:37 pm

Hello again :)

Is it possible to create the folder on installation, before the app is first launched? (The post indicates the folder will be created only when the app is started, and that is also the behavior I've seen, but I would want it to be created during the installation itself)

thanks

Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Create Application files and folders outside of VFS during MSIX install

Tue Aug 22, 2023 7:58 am

Hello,

I'm afraid that would not be possible, at least not with the current MSIX support.

If you have any other questions, please let us know and we will gladly assist!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”