How do I use PowerShell commands to change Permissions for a Registry?


  1. Posts : 79
    Windows 10 x64 21H1
       #1

    How do I use PowerShell commands to change Permissions for a Registry?


    Hi, everyone
    My main objective is make the registry key "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2"
    more safer and not auto run programs.

    Secondly, I hoped the PowerShell command codes could batch run them automatically.

    Protected the registry key before:
    How do I use PowerShell commands to change Permissions for a Registry?-protected-registry-key-before.jpg
    After protected the registry key:
    How do I use PowerShell commands to change Permissions for a Registry?-after-protected-registry-key.jpg

    I had some PowerShell command codes about the aforementioned registry key.
    $path = "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2"
    $Acl = Get-ACL $path
    $AccessRule= New-Object System.Security.AccessControl.RegistryAccessRule("Everyone","FullControl","Deny")
    $Acl.SetAccessRule($AccessRule)
    Set-Acl $path $Acl

    Q.Could you please help me to correct them and tell me what command codes used to batch run them automatically.

    Thanks a lot.
      My Computer


  2. Posts : 59
    Version 10.0.22000.258
       #2

    I can't look at your script right now, but use Windows Task Scheduler to run it automatically.
      My Computer


  3. Posts : 12,022
    Windows 10 Home x64 Version 21H2 Build 19044.1889
       #3

    I suggest you study this instead Turn On or Off AutoPlay - TenForumsTutorials

    There are lots of other ways to run programs automatically. A very well regarded tool for investigating this is MS SysInternals AutoRuns for Windows
    There is a lot of guidance available for this tool.
    autoruns ditty by dalchina - TenForums
    AutoRuns can find Hidden Scheduled Tasks - WindowsExplored
    Autoruns for Windows - Windows Sysinternals - MSDocs


    Denis
      My Computer


  4. Posts : 79
    Windows 10 x64 21H1
    Thread Starter
       #4

    Try3 said:
    I suggest you study this instead Turn On or Off AutoPlay - TenForumsTutorials

    There are lots of other ways to run programs automatically. A very well regarded tool for investigating this is MS SysInternals AutoRuns for Windows
    There is a lot of guidance available for this tool.
    autoruns ditty by dalchina - TenForums
    AutoRuns can find Hidden Scheduled Tasks - WindowsExplored
    Autoruns for Windows - Windows Sysinternals - MSDocs


    Denis
    Thanks, Denis.
    I will try to use Autoruns for Windows.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 23:09.
Find Us




Windows 10 Forums