SOLVED

INI settings in App Directory issue

%3CLINGO-SUB%20id%3D%22lingo-sub-1519703%22%20slang%3D%22en-US%22%3EINI%20settings%20in%20App%20Directory%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1519703%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20MSIX%20package%20an%20application%20that%20uses%20an%20INI%20file%20stored%20in%20the%20Application%20Directory%20itself%20to%20coordinate%20connections%20to%20an%20SQL%20server.%26nbsp%3B%20Is%20there%20a%20way%20that%20I%20can%20tell%20my%20MSIX%20package%20to%20store%20this%20INI%20file%20in%20the%20user%20APPDATA%2FProfile%20folder%20and%20reference%20it%20there%20vice%20looking%20at%20C%3A%5CProgram%20Files%20(X86)%5C%3CAPPLICATION%3E%5Ccontrol.ini%20file%3F%26nbsp%3B%3C%2FAPPLICATION%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20design%20you%20cannot%20edit%20anything%20in%20the%20application%20directory%20when%20deploying%20the%20MSIX%20app.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3Ejohn%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1519703%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eapp-attach%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMSIX%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVDI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWVD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1520825%22%20slang%3D%22en-US%22%3ERe%3A%20INI%20settings%20in%20App%20Directory%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1520825%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F32035%22%20target%3D%22_blank%22%3E%40John%20Wildes%3C%2FA%3E%26nbsp%3B%20Can%20you%20please%20clarify%20what%20you%20want%20a%20bit%20more%3F%26nbsp%3B%20Possible%20examples%20include%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EI%20just%20want%20the%20app%20to%20use%20the%20file%20but%20allow%20the%20file%20content%20to%20be%20changed%20by%20the%20app.%3C%2FLI%3E%0A%3CLI%3EI%20want%20the%20file%20in%20that%20particular%20location%20because%20I%20use%20a%20third%20party%20tool%20to%20manage%20it%20from%20that%20location%20and%20roam%20it%20for%20the%20user.%3C%2FLI%3E%0A%3CLI%3EI%20want%20the%20ini%20file%20kept%20completely%20out%20of%20the%20package%20and%20will%20be%20managed%20externally%20or%20using%20package%20scripts.%20I%20just%20want%20the%20app%20to%20look%20for%20it%20there.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1520842%22%20slang%3D%22en-US%22%3ERe%3A%20INI%20settings%20in%20App%20Directory%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1520842%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146612%22%20target%3D%22_blank%22%3E%40TIMOTHY%20MANGAN%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20suggestions!%26nbsp%3B%20I%20realize%20I%20might%20not%20have%20been%20clear%20in%20my%20description%20of%20what%20I%20wanted.%26nbsp%3B%20This%20is%20what%20I'm%20looking%20for%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EI%20want%20the%20ini%20file%20kept%20completely%20out%20of%20the%20package%20and%20will%20be%20managed%20externally%20or%20using%20package%20scripts.%20I%20just%20want%20the%20app%20to%20look%20for%20it%20there.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThoughts%20on%20how%20to%20accomplish%20this%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1520859%22%20slang%3D%22en-US%22%3ERe%3A%20INI%20settings%20in%20App%20Directory%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1520859%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F32035%22%20target%3D%22_blank%22%3E%40John%20Wildes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20if%20I%20assume%20that%20changing%20the%20code%20of%20the%20app%20isn't%20an%20option%20and%20that%20you%20are%20repackaging%2C%20I%20would%20look%20at%20one%20of%20two%20methods%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%26nbsp%3BUse%20the%20Application%20Compatibility%20Toolkit%20from%20the%20Microsoft%20ADK%20to%20create%20a%20custom%20file%20redirection%20fixup.%26nbsp%3B%20This%20is%20done%20prior%20to%20the%20packaging.%26nbsp%3B%20You%20identify%20the%20exe%20and%20create%20a%20compatibility%20shim%20with%20a%20file%20redirection%20rule%20for%20that%20one%20file%20pointing%20to%20the%20external%20location.%20The%20output%20of%20this%20will%20be%20a%20%22.sdb%22%20file.%26nbsp%3B%20Then%20just%20package%20the%20app%20as%20normal.%20You%20will%20have%20to%20cause%20the%20sdb%20file%20to%20be%20coped%20to%20target%20systems%20and%20installed%20using%20the%20%22sdbinst.exe%22%20OS%20utility.%20Since%20this%20must%20be%20performed%20before%20the%20user%20starts%20the%20application%2C%20MSIX%20package%20scripting%20is%20not%20an%20option%20to%20do%20the%20sdbinst%20(which%20needs%20elevation%20anyway).%20So%20you'd%20be%20using%20an%20external%20method%20to%20copy%20the%20sbd%20and%20ini%20files%20and%20running%20the%20command.%3C%2FLI%3E%0A%3CLI%3ERepackage%20the%20app%20using%20the%20Package%20Support%20Framework%20and%20include%20the%20FileRedirectionFixup.%26nbsp%3B%20This%20will%20cause%20an%20automatic%20read%20redirection%20to%20the%20%25AppDataLocal%25%2FPackages%20folder%20for%20the%20package.%26nbsp%3B%20If%20packaging%20using%20the%20Microsoft%20MSIX%20Packaging%20Tool%20you%20can%20use%20PsfTooling%20to%20add%20and%20configure%20the%20PSF%20into%20the%20package.%26nbsp%3B%20Just%20ask%20for%20the%20FileRedirectionFixup%20and%20keep%20the%20default%20settings.%26nbsp%3B%20You%20can%20then%20use%20your%20external%20method%20to%20deploy%20the%20file%20to%20the%20place%20the%20app%20under%20the%20redirected%20location.%26nbsp%3B%20The%20exact%20path%20under%20the%20%22Packages%22%20folder%20will%20depend%20on%20how%20you%20package.%20Since%20you%20are%20now%20using%20the%20PSF%2C%20you%20can%20also%20add%20start%20of%20application%20script%20to%20perform%20the%20ini%20file%20copy%20for%20you.%26nbsp%3B%20The%20PsfScripting%20has%20a%20pseudo-variable%20%25MSIXWritablePackageRoot%25%20which%20can%20be%20helpful.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ENeither%20method%20is%20simple%20to%20provide%20detailed%20instructions%2C%20but%20the%20above%20outlines%20the%20basic%20techniques.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1520887%22%20slang%3D%22en-US%22%3ERe%3A%20INI%20settings%20in%20App%20Directory%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1520887%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146612%22%20target%3D%22_blank%22%3E%40TIMOTHY%20MANGAN%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20insight!%20I%20don't%20spend%20any%20time%20doing%20this%20at%20all%2C%20but%20I%20understand%20what%20you're%20explaining.%26nbsp%3B%20I'll%20dig%20into%20these%20two%20options.%26nbsp%3B%20Would%20you%20happen%20to%20have%20any%20links%20to%20Microsoft%20documentation%20surrounding%20the%20concepts%20that%20you're%20explaining%20below%3F%26nbsp%3B%20I've%20got%20some%20promising%20results%20from%20my%20search%20queries%2C%20but%20if%20you%20have%20some%20favorites%20that%20you%20can%20share%20that%20would%20be%20awesome.%3C%2FP%3E%3CP%3EThanks%20again!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1520947%22%20slang%3D%22en-US%22%3ERe%3A%20INI%20settings%20in%20App%20Directory%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1520947%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F32035%22%20target%3D%22_blank%22%3E%40John%20Wildes%3C%2FA%3E%26nbsp%3BDocumentation%20is%20pretty%20light.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20AppCompat%20Toolkit%20you%20look%20for%20videos%20by%20Chris%20Jackson.%26nbsp%3B%20He%20has%20old%2C%20but%20great%20videos%20showing%20how%20to%20do%20it.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20the%20Psf%2C%20there%20is%20minimal%20docs%20on%20this%20topic%20(if%20any)%20via%20aka.ms%2FMSIX%20.%20The%20GitHub%20repro%26nbsp%3Bhas%20scripting%20examples%20in%20the%20readme%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FMSIX-PackageSupportFramework%2Ftree%2Fmaster%2FPsfLauncher%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2FMSIX-PackageSupportFramework%2Ftree%2Fmaster%2FPsfLauncher%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20have%20some%20PsfTooling%20documentation%20and%20videos%20on%20my%20site%20at%20tmurgent.com%20(although%20nothing%20on%20scripting%20at%20this%20point).%26nbsp%3B%20We%20do%20cover%20this%20sort%20of%20thing%20in%20our%20paid-for%20trainings.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi all

I am trying to MSIX package an application that uses an INI file stored in the Application Directory itself to coordinate connections to an SQL server.  Is there a way that I can tell my MSIX package to store this INI file in the user APPDATA/Profile folder and reference it there vice looking at C:\Program Files (X86)\<Application>\control.ini file? 

 

By design you cannot edit anything in the application directory when deploying the MSIX app.  

 

thanks

john

5 Replies

@John Wildes  Can you please clarify what you want a bit more?  Possible examples include:

  • I just want the app to use the file but allow the file content to be changed by the app.
  • I want the file in that particular location because I use a third party tool to manage it from that location and roam it for the user.
  • I want the ini file kept completely out of the package and will be managed externally or using package scripts. I just want the app to look for it there.

 

@TIMOTHY MANGAN 

 

Thank you for the suggestions!  I realize I might not have been clear in my description of what I wanted.  This is what I'm looking for :

 

  • I want the ini file kept completely out of the package and will be managed externally or using package scripts. I just want the app to look for it there.

Thoughts on how to accomplish this?  

Best Response confirmed by John Wildes (Contributor)
Solution

@John Wildes 

 

So if I assume that changing the code of the app isn't an option and that you are repackaging, I would look at one of two methods:

  1.  Use the Application Compatibility Toolkit from the Microsoft ADK to create a custom file redirection fixup.  This is done prior to the packaging.  You identify the exe and create a compatibility shim with a file redirection rule for that one file pointing to the external location. The output of this will be a ".sdb" file.  Then just package the app as normal. You will have to cause the sdb file to be coped to target systems and installed using the "sdbinst.exe" OS utility. Since this must be performed before the user starts the application, MSIX package scripting is not an option to do the sdbinst (which needs elevation anyway). So you'd be using an external method to copy the sbd and ini files and running the command.
  2. Repackage the app using the Package Support Framework and include the FileRedirectionFixup.  This will cause an automatic read redirection to the %AppDataLocal%/Packages folder for the package.  If packaging using the Microsoft MSIX Packaging Tool you can use PsfTooling to add and configure the PSF into the package.  Just ask for the FileRedirectionFixup and keep the default settings.  You can then use your external method to deploy the file to the place the app under the redirected location.  The exact path under the "Packages" folder will depend on how you package. Since you are now using the PSF, you can also add start of application script to perform the ini file copy for you.  The PsfScripting has a pseudo-variable %MSIXWritablePackageRoot% which can be helpful.

Neither method is simple to provide detailed instructions, but the above outlines the basic techniques.

@TIMOTHY MANGAN 

 

Thank you for the insight! I don't spend any time doing this at all, but I understand what you're explaining.  I'll dig into these two options.  Would you happen to have any links to Microsoft documentation surrounding the concepts that you're explaining below?  I've got some promising results from my search queries, but if you have some favorites that you can share that would be awesome.

Thanks again!

@John Wildes Documentation is pretty light. 

 

For AppCompat Toolkit you look for videos by Chris Jackson.  He has old, but great videos showing how to do it.  

 

For the Psf, there is minimal docs on this topic (if any) via aka.ms/MSIX . The GitHub repro has scripting examples in the readme here: https://github.com/microsoft/MSIX-PackageSupportFramework/tree/master/PsfLauncher

 

I have some PsfTooling documentation and videos on my site at tmurgent.com (although nothing on scripting at this point).  We do cover this sort of thing in our paid-for trainings.