Jump to content

Changing Registry Permission level


Recommended Posts

Hi,

Can someone please show me a code for changing the permission level for a Registry Key.

I am trying to delete a value but it is not possible as the Key permission is set as "Read Only". And I want to know a way to change the Key "Test" as Full Control.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TEST

Link to comment
Share on other sites

ok, I needed to delete a file (Temp) inside the Key TEST and I got the command line working for that

reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TEST" /v Temp /f"

This works from the command prompt. But when I put this into code, it doesn't work. what am I doing wrong?

RunWait(@ComSpec & " /c " & "reg delete " & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TEST" & " /v Temp /f", "", @SW_HIDE)

 

Link to comment
Share on other sites

Ok, I got this part atleast as per below... but this is still not working because of permissions issue.

I checked your suggestion but not able to figure it out...

RunWait(@ComSpec & " /c reg delete " & '"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TEST" /v Temp /f', "", @SW_HIDE)

 

Edited by sunshinesmile84
Link to comment
Share on other sites

You need #RequireAdmin on top of your script to elevate to admin privileges:

#RequireAdmin
RunWait(@ComSpec & " /c reg delete " & '"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TEST" /v Temp /f', "", @SW_HIDE)

Works for me with that exact same key (and doesn't work without the directive).

By the way, I suggest you change the /c to /k and the @SW_HIDE to @SW_SHOW while you are developing/testing, as the command prompt window will remain open (until you close it manually of course) and you'll be able to see the feedback. In this case either that the operation completed successfully or that it failed because access denied. Then after you get it working, change it back to hidden mode.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...