How to change Registry Permissions with RegIni.exe (VBScript)


Hi all, welcome back,


Today I'll show how we can set the following permissions on a registry key with RegIni.exe and a VBScript:


- Creator Owner Full Control
- Users Full Control
- Power Users Full Control
- Administrators Full Control
- System Full Control


I will set the permissions here for testing purposes:


- HKEY_CLASSES_ROOT\AlejaCMaTypelib
- HKEY_LOCAL_MACHINE\Software\AlejaCMaCo\AlejaCMaApp

And for that I will need to create a special regini.exe script which will have the following contents:


HKEY_LOCAL_MACHINE\Software\Classes\AlejaCMaTypelib [1 5 7 11 17]
HKEY_LOCAL_MACHINE\Software\AlejaCMaCo\AlejaCMaApp [1 5 7 11 17]


Notes:
- With regini.exe I won't be able to set Users Full Control, but Everyone Full Control.
- HKEY_CLASSES_ROOT = HKEY_LOCAL_MACHINE\Software\Classes

See the following articles for details on the values used in the regini script:
- How to Use Regini.exe to Set Permissions on Registry Keys
- How to: Use a Script to Change Registry Permissions from the Command Line


And here you have the VBScript that will use regini.exe and its script:


 

' Create temp file with the script that regini.exe will use
'
set oFSO = CreateObject("Scripting.FileSystemObject")
strFileName = oFSO.GetTempName
set oFile = oFSO.CreateTextFile(strFileName)
oFile.WriteLine "HKEY_LOCAL_MACHINE\Software\Classes\AlejaCMaTypelib [1 5 7 11 17]"
oFile.WriteLine "HKEY_LOCAL_MACHINE\Software\AlejaCMaCo\AlejaCMaApp [1 5 7 11 17]"
oFile.Close

' Change registry permissions with regini.exe
'
set oShell = CreateObject("WScript.Shell")
oShell.Run "regini " & strFileName, 8, true

' Delete temp file
'
oFSO.DeleteFile strFileName

WScript.Echo "Done!"


 


I hope it helps.


Cheers,


 


Alex (Alejandro Campos Magencio)

Comments (15)
  1. Adam M. says:

    How do you change registry keys through a batch file and regini?  For example, we’d like to have Vista auto-logon with a user name and password.  We could do it through XP, but it isn’t working quite the same in Vista.  Any suggestions?

  2. I’ve never used Regini.exe for anything but changing registry key permissions, but this link may help you:

    Distributing Registry Changes

    http://windowsitpro.com/Windows/Articles/ArticleID/20047/pg/4/4.html

    In order to change registry key values, etc., I always use VBScript. See this sample for instance:

    How Can I Create a New Registry Key?

    http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov06/hey1116.mspx

    I hope this helps.

  3. User says:

    Thank you very much for your useful help…!

  4. techiem2 says:

    Would you happen to know if there is a way to use regini or something similar to change permissions for a particular user?

    The ACL options for regini only shows default system users/groups.

    We need to change permissions on a bunch of keys for a special user that will be created and need to automate the permissions process (it would be annoying to have to manually set the permissions on 20+ keys at several machines…)

    Thanks!

  5. Disk4mat says:

    How can I change the owner of a key? I tried the script on a key where "TrustedInstaller" is the owner and the permissions cant be changed.

    In regedit I can manualy change the owner to Administrators then the script works. So how can I script changing the owner?

    TIA

  6. I’m sorry Disk4mat. I have no sample for that. If you need help to create one please contact us, Microsoft Technical Support, and we will be more than happy to assist you.

    Cheers,

    Alex

  7. KarlKroger says:

    Does anyone know how to reset a reg key’s permissions back to "inherit from parent"?

  8. mohsen zali says:

    How to change Registry Permissions with RegIni.exe (VBScript)

  9. xyzam says:

    How can I change the owner of a key? I tried the script on a key where "TrustedInstaller" is the owner and the permissions cant be changed.

    In regedit I can manualy change the owner to Administrators then the script works. So how can I script changing the owner?

    Even I am also looking for trustedinstaller

  10. Tim Mayville says:

    rem –  You  can do it with one batch file or cmd if you like…

    rem –  In Win7, 8, 8.1-svr 2008,2012

    @echo off

    title "Creating Registry Security for a tag…."

    @echo HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment  [1 5 7 11 14 17 21] >%public%desktopfile.fil

    @regini /m \localhost %public%desktopfile.fil

    @del %public%desktopfile.fil

    exit

    enjoy…

  11. Enrique G. says:

    Can this be used to help keep Windows secure?

    Thanks,

  12. uday kiran reddy says:

    But Regini is deleting the previous permissions existed and adding the permissions we gave.And also it is not appending those permissions to sub keys.

    Is there any extra options or other solution to give permissions to sub keys and also to append with the previous permissions instead of replacing them.

  13. uday says:

    But Regini is deleting the previous permissions existed and adding the permissions we gave.And also it is not appending those permissions to sub keys.

    Is there any extra options or other solution to give permissions to sub keys and also to append with the previous permissions instead of replacing them.

Comments are closed.

Skip to main content