Is it possible to use powershell command to enable file access option in windows settings?

Xie Steven 811 Reputation points
2022-11-25T02:08:45.34+00:00

Hello,

I'm developing a business UWP app for sideloading. The app will read and write to the file which is out of the App domain. For example, the file path is c:\\folder1\\1.txt

I followed the document File access permissions, and add the capability broadFileSystemAccess. After the app is deploied on my customers' machines, I need to let my customers to go to the Settings > Privacy > File system and enable the file access option for my app at first, then the app will work well.

My customers do not want to do this step(enable file access option) manually. They want a automatic way to do it. Is it possible to use powershell to achieve this target? or other better ways?

Thanks,
Steven

Universal Windows Platform (UWP)
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,448 questions
0 comments No comments
{count} votes

Accepted answer
  1. Junjie Zhu - MSFT 16,471 Reputation points Microsoft Vendor
    2022-11-25T07:49:23.337+00:00

    Hello, @Xie Steven ,
    Welcome to Microsoft Q&A!

    You can go to Registry [Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\broadFileSystemAccess].

    If you have installed your application, you can see your app's package family name.

    Modify the Value Data to Allow.

    You can use Powershell to set the registry.

     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\broadFileSystemAccess\[your package family name]" -Name "Value" -Value "Allow"  
    

    264090-image.png

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful