How to change permission in registry sub keys?

Hi 
I use script take ownership of a registry key and change permissions.
Below is my powershell script, It can take ownership and change permissions to administrators group.
But It only effected root registry key folder not sub keys.
How to modify script can take ownership and change permissions in root keys and all sub keys?
function enable-privilege {
param(
## The privilege to adjust. This set is taken from
## http://msdn.microsoft.com/en-us/library/bb530716(VS.85).aspx
[ValidateSet(
"SeAssignPrimaryTokenPrivilege", "SeAuditPrivilege", "SeBackupPrivilege",
"SeChangeNotifyPrivilege", "SeCreateGlobalPrivilege", "SeCreatePagefilePrivilege",
"SeCreatePermanentPrivilege", "SeCreateSymbolicLinkPrivilege", "SeCreateTokenPrivilege",
"SeDebugPrivilege", "SeEnableDelegationPrivilege", "SeImpersonatePrivilege", "SeIncreaseBasePriorityPrivilege",
"SeIncreaseQuotaPrivilege", "SeIncreaseWorkingSetPrivilege", "SeLoadDriverPrivilege",
"SeLockMemoryPrivilege", "SeMachineAccountPrivilege", "SeManageVolumePrivilege",
"SeProfileSingleProcessPrivilege", "SeRelabelPrivilege", "SeRemoteShutdownPrivilege",
"SeRestorePrivilege", "SeSecurityPrivilege", "SeShutdownPrivilege", "SeSyncAgentPrivilege",
"SeSystemEnvironmentPrivilege", "SeSystemProfilePrivilege", "SeSystemtimePrivilege",
"SeTakeOwnershipPrivilege", "SeTcbPrivilege", "SeTimeZonePrivilege", "SeTrustedCredManAccessPrivilege",
"SeUndockPrivilege", "SeUnsolicitedInputPrivilege")]
$Privilege,
## The process on which to adjust the privilege. Defaults to the current process.
$ProcessId = $pid,
## Switch to disable the privilege, rather than enable it.
[Switch] $Disable
## Taken from P/Invoke.NET with minor adjustments.
$definition = @'
using System;
using System.Runtime.InteropServices;
public class AdjPriv
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
public int Count;
public long Luid;
public int Attr;
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int SE_PRIVILEGE_DISABLED = 0x00000000;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
public static bool EnablePrivilege(long processHandle, string privilege, bool disable)
bool retVal;
TokPriv1Luid tp;
IntPtr hproc = new IntPtr(processHandle);
IntPtr htok = IntPtr.Zero;
retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
if(disable)
tp.Attr = SE_PRIVILEGE_DISABLED;
else
tp.Attr = SE_PRIVILEGE_ENABLED;
retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
return retVal;
$processHandle = (Get-Process -id $ProcessId).Handle
$type = Add-Type $definition -PassThru
$type[0]::EnablePrivilege($processHandle, $Privilege, $Disable)
enable-privilege SeTakeOwnershipPrivilege
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing",[Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree,[System.Security.AccessControl.RegistryRights]::takeownership)
# You must get a blank acl for the key b/c you do not currently have access
$acl = $key.GetAccessControl([System.Security.AccessControl.AccessControlSections]::None)
$me = [System.Security.Principal.NTAccount]"Administrators"
$acl.SetOwner($me)
$key.SetAccessControl($acl)
# After you have set owner you need to get the acl with the perms so you can modify it.
$acl = $key.GetAccessControl()
$inherit = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit"
$propagation = [System.Security.AccessControl.PropagationFlags]"None"
$rule = New-Object System.Security.AccessControl.RegistryAccessRule "Administrators","FullControl",$inherit,$propagation,"Allow"
$acl.SetAccessRule($rule)
$key.SetAccessControl($acl)
$key.Close()

Hi jrv
How to explicitly take ownership of the subkey?
System.Security.AccessControl.InheritanceFlags 
I try use value
"ContainerInherit、ObjectInherit、None", and It only take permission in root key.

Similar Messages

  • How to change an e-mail sub-account password?

    Our e-mail has been hacked. I recently changed my password but don't know how to change my spouse's sub-account password.

    Your email account passwords are administered with your email provider. You have to work with them to change the account password. Most providers have a link to reset passwords on their email help page.
    This page tells you how to remove and replace stored passwords in Thunderbird after changing them with your provider.https://kb.wisc.edu/page.php?id=19006

  • How to change SCCM 2012 R2 Product key?

    Dear All
    I need changing SCCM 2012 R2 product Key i was using another company Product key by mistake, i discovered that after finishing installation and Configuration my server become a live now so can any one help me to change it.
    note:-
    No way to remove the site and reinstall again.
    Thanks for your help in Advance.

    You change your product key by running ConfigMgr 2012 setup. You can following this guide for how-to: http://www.ronnipedersen.com/2012/05/convert-system-center-2012-from-evaluation-to-full-product-version/
    Normally this procedure is for changing the evaluation version of ConfigMgr 2012 to the full version by specifying a full version product key.
    I have done a lot of ConfigMgr 2012 installations for various customers and the key has always been the same.
    Thanks, but its already activated with another key and i cannot find this option

  • How to change permission file

    i have an old file in my website lhokseumawe dalam angka for year 2004, 2005 and more
    you can check it here: http://www.bappedalhokseumawe.web.id/lhokseumawe-dalam-angka
    but i lost the original one because the person making the file is not there or retire.
    how do i change permission for copy, print,etc
    please help me, because this is important file for the local goverment in my place
    thanks

    sorry for not clear question, what i mean is Document restriction summary
    Printing                                              : Allowed
    Document Assembly                          : Not Allowed
    Content  Copying                               :Not Allowed
    Content  Copying for accessibilty       : Allowed
    etc
    how do i change permission to be allowed or not ?

  • HOW TO CHANGE COLOR ON LITTLE SUB TITLE BAR UNDER THE HEADING?

    Hi,
    I was successfully able to change the background color on the templates headed, but that little bar under it, that displays the links to your other pages within the site did not change with it, and I have tried everything but have not been successful. How do I do this?
    Thanks
    Jennifer

    Those navbar links are generated by javascript and are not user editable. You can create your own navbar using a Text Based Navbar and then have complete control over font (stick with the Web Safe Fonts), color, size and rollover colors.
    Cyclosaurus has posted an HTML snippet that can change the font style of the navbar of each page that the snippet is applied to. You can find it here: http://discussions.apple.com/message.jspa?messageID=8596966#8596966. This page tells how tol change the navbar test to all caps: http://discussions.apple.com/thread.jspa?messageID=8523772#8523772.
    And the following code, again courtesy of Cyclosaurus will change the rollover color of the navbar on any page the snippet is added to:
    HTML Widget to change rollover color for this page in the navbar above to orange The code used, courtesy of Cyclosurus, is:
    <script type='text/javascript'>
    styleCSS = 'div#widget0 li a:hover{color: orange;}'; // change color to your liking;
    eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[func tion(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'e(c)'\\b','g'),k[c]);return p}('1=2.3.5(\'6\');1.4.7=\'8/9\';1.4(\'a\',\'b\');1.c=d;2.3.e(\'f\')[0].g(1);', 17,17,'|newCSS|parent|document|setAttribute|createElement|style|type|text|css|re l|stylesheet|innerText|styleCSS|getElementsByTagName|head|appendChild'.split('|' ),0,{})); </script>
    You can see an example of that in this demo page: Misc. Items.
    OT

  • How to change the Windows Registry to enable FIPS 140 in Acrobat Pro XI?

    Is there a set of instructions that identifies the registry key to enable FIPS 140?

    http://www.adobe.com/devnet-docs/acrobatetk/tools/PrefRef/Windows/AVGeneral.html#FIPSCompl iance
    Also some general info: 2   Pre-deployment Configuration — Digital Signatures Guide for IT
    hth,
    Ben

  • How to change color of DHTML sub menu list

    Hi all,
    In my application i am using DHTML submenu list. But I have to change the color of
    the menu list which is selected currently.
    In interactive report how to fix the column width , because if one column has big string it's going to the right side. My requirement is after fixed column width it has to come in the second line.
    pls help me. I am in urgent need.
    thnks
    pnr

    im a bit confused with the post so hopefully this will help you, if not then let me know.
    I think the problem is that in your renderer your saying
    setBackground(header.getBackground());which is setting the backgound of the renderer rather than the selected item, please see an example below, I created a very simple program where it adds JLabels to a list and the renderer changes the colour of the selected item, please note the isSelected boolean.
    Object "value" is the currentObject its rendering, obviously you may need to test if its a JLabel before casting it but for this example I kept it simple.
    populating the list
    public void populateList(){
            DefaultListModel model = new DefaultListModel();
            for (int i=0;i<10;i++){
                JLabel newLabel = new JLabel(String.valueOf(i));
                newLabel.setOpaque(true);
                model.addElement(newLabel);           
            this.jListExample.setModel(model);
            this.jListExample.setCellRenderer(new RowHeaderRenderer());
        }the renderer
    class RowHeaderRenderer extends JLabel implements ListCellRenderer
        JTable theTable = null;
        public Component getListCellRendererComponent(JList list, Object value,
                                                      int index, boolean isSelected, boolean cellHasFocus){
            JLabel aLabel = (JLabel)value;
            if (isSelected){
                aLabel.setBackground(Color.RED);
            }else{
                aLabel.setBackground(Color.GRAY);
            return aLabel;       
    }

  • HT1553 how to change permission for my external hard-disk ??????

    can't copy files from my mac to hard disk

    You could select the 'Ignore ownership on this volume' box in Get Info for the disk - see below - unlock the lock first:

  • How to change chords & keys for loops?

    Hey, guys! I'm a total newbie, so I was hoping someone could give me "step-by-step" instructions for how to do this.... I am creating a song using one of the blue acoustic guitar loops in Logic Pro 9 & I have the option to "Play in" any chord/key imaginable when I am listening to the various loops... However, when I drag the loop over to the work area, it reverts back to the original key & I have no idea how to change it to the preferred key. I want to use this same loop throughout the song, but I need to be able to change the key several times in order to create my own chord progressions.... Any idea how I can make this happen? Thanks!!!!

    May I dare to tell you the magic four letters?
    But to give you a hint: learn how to configure global tracks, activate the chord track and look if you find the epic answer there
    Fox

  • Changing the formula to a key figure on a query

    Hello All,
    I do not have access to BEx. I would please like to know how to change the formula to a key figure "Total $" in a QD Promo Analysis query (technical name - N03_Q_D_N03_SD_502_0003). Will transaction RSRT take me to the query and eventually the formula so I can change it? If so please give me guidance as this is the first time I go into transaction RSRT. If there is another way please also give guidance.
    Thank you and kind regards
    Keith Kibuuka

    Hi Vishvesh,
    Thank you for your response. Maybe access to BEx was the wrong word - I do have access although I was trying to avoid configuring the SAP logon to add this particular client onto because I have not done this before. My boss has helped me and I have now have "access".
    Therefore from the query designer can you please guide me on how to change the formula to a key figure on a query? Input from all people is also be very much appreciated.
    Thank you and kind regards,
    Keith

  • How to change or Switch - scroll direction - automatic using registry keys

    how to change or Switch - scroll direction on TouchPad Synaptics - automatic using registry keys   ?

    Hi jrv
    How to explicitly take ownership of the subkey?
    System.Security.AccessControl.InheritanceFlags 
    I try use value
    "ContainerInherit、ObjectInherit、None", and It only take permission in root key.

  • Permission to registry key

    When I try:
    Set PDFForm = CreateObject("AFormAut.App")
    I get this error:
    The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID
    {7CD069A1-50AA-11D1-B8F0-00A0C9259304}
    and APPID Unavailable to the user NT AUTHORITY\IUSR SID (S-1-5-17) from address LocalHost (Using LRPC). This security permission can be modified using the Component Services administrative tool.
    But in Component Services there is no an object with such GUID. How can I open permission to registry key?

    What version and product is in use?
    Is this on a normal workstation with a logged in user running the app, and Acrobat visible to the user?

  • How to change the presets in pop-up menus (CS6 or CR 7, example Photo Filter) with arrow keys?

    How to change the presets in pop-up menus (CS6 or CR 7, example Photo Filter) with arrow keys an see at the same time the changes on the photo?
    It worked under Windows, now I use OS 10.8 and have to apply a preset with a click or Return button but after that the pop-up menu close so I have to open it once again to change a preset. Please help. Thank you!

    The filter panel is a shortcut for the content panel and it only effects the content of that window. So if you have a folder it will only see this as a folder and not with its content. (a Stack behaves about the same, being different in only counting the first file in the filter panel criteria but not what is in the stack itself)
    You have a view work arounds, first is use menu view / show items from subfolders (this can take some time especially if you have not used caching before on this content) and this builds visible thumbs for all content and that can be used for filtering.
    Or use the find command (Edit / find) and inhere specify the source and fill in the criteria include subfolders and this will give you the correct result.
    When you create a smart collection the find command also pops up given you the same opportunity to get the results in a collection, but since a collection is only a bunch of aliases referring to the originals you might be a bit careful with editing and deleting.

  • How to change primary keys of existing InfoCube.

    Greetings everyone!
    I’m trying to change the Key Fields in my reporting architecture as per our new company mandate.  I’ve been able to successfully change the primary keys for DS, DSO and InfoSource.  Can any kind soul out there please tell me how to change the primary keys on an existing InfoCube?  I will surely appreciate all the assistance I can get.  Its kinda urgent!
    Regards,
    Philips

    Hi,
    Check the possibility with Remodelling option . If it is not possible with Remodelling, then you can only change the cube deleting the Data.
    With rgds,
    Anil Kumar Sharma .P

  • How to change a massive amount of foreign keys?

    Hi to all!
    I'm a newbie here, and I hope I'll find a solution to my problem...
    Well, I have to create a copy of row within the same table, with same values except of primary key. That part is ok. Then, I have to change values of that primary key (from old value, to new value) in all foreign keys which references to that column/primary key in parent table. Let's say that isn't problem too, using system tables and informations about constraints and indexes...
    But, tricky part comes. Some of those foreign keys are primary keys for their tables, and there are other foreign keys which references to these primary keys, including a column which is primary key in very first (parent) table. And also, that line of primary key-foreign key can go on...
    I don't know how deep to check for those keys. Any help with some piece of code (in PL/SQL)? Also, how to start to change value of that, particular column, in line of primary key-foreign key?

    Sounds like you need to add a copy function to your application. This will allow you to create a copy of an existing import/export but each will be unique. This would provide you with the ability to change the import/export and retain the old and new details.
    A small example using a header and detail table;
    select * from orders;
      ORDER_ID ORDER_DATE
             1 27/05/2010
    select * from order_lines;
       LINE_ID   ORDER_ID
             1          1
             2          1
             3          1A function that makes a copy of a certain order;
    create or replace function copy_order(p_order_id orders.order_id%type)
      return number is
      l_new_order_id orders.order_id%type;
    begin
      select orders_seq.nextval
      into l_new_order_id
      from dual;
      insert into orders
        (order_id, order_date)
        select l_new_order_id, sysdate
        from orders
        where order_id = p_order_id;
      insert into order_lines
        (line_id, order_id)
        select order_lines_seq.nextval, l_new_order_id
        from order_lines
        where order_id = p_order_id;
      return l_new_order_id;
    end;
    Function createdCall the function with order_id 1;
    var n number
    exec :n := copy_order(1);
    PL/SQL procedure successfully completed
    print n
    n
    2There are now 2 similar orders;
    select * from orders;
      ORDER_ID ORDER_DATE
             1 27/05/2010
             2 28/05/2010
    select * from order_lines;
       LINE_ID   ORDER_ID
             1          1
             2          1
             3          1
             4          2
             5          2
             6          2
    6 rows selectedThe first order can be canceled (using a status column or similar) and the second order can be updated, ie add additional lines, etc. or left as is.

Maybe you are looking for

  • Link on background image

    I created and inserted a  background image in the Container. It includes "link buttons" built into the image in Photoshop, meaning images intended to be clicked in order to move to another page.  I can't create hotspots/image maps to use to create li

  • Can I Install SOA Suite 10.1.3.1 on Enterprise Linux 64 bit ?

    Hi everyone. I just downloaded and installed Oracle Enterprise Linux 5.1 for x86_64. I tried installing SOA suite 10.1.3.1 and failed the distro check. I then tried to do this with the ignoreSysPreReqs switch and got the following exception : /tmp/Or

  • UTC Date/Time conversion

    Is there a documented formula for converting UTC date/time stamps in CallDetailRecords (e.g., 1074902387) to a recognizable time/date?

  • Nokia 6080 and DKU 5

    Hi everyone, I have a Nokia 6080 and i bought a new DKU-5 Data Cable, I downloaded the latest nokia pc suite from nokia website., and the DKU cable driver from the Nokia Site., when I run Pc suite according to the steps it says connect your data cabl

  • Transport infoobject data element?

    Hi All, I created a new key figure in the development system with numeric type and 3 decimal places. I transported it to the quality system. Everything went well. After I changed the decimals places from 3 to 9 in the development system. I created a