Jump to content

Delete registry key only if its empty


Go to solution Solved by supraspecies,

Recommended Posts

  • Solution

Yes, thanks. Was able to come up with a solution:

RegEnumKey ('HKCU\Software\techPowerUp', 1)
$nokeys=(@error=-1)
RegEnumVal ('HKCU\Software\techPowerUp', 1)
$novalues=(@error=-1)
If $nokeys And $novalues Then RegDelete ('HKCU\Software\techPowerUp') 

I was trying to delete empty "techPowerUp" key. With the above code, it deletes only if there are no keys and values in it. Let the code be here for anyone who needs it since I wasn't able to find an answer when I searched.

Edited by supraspecies
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...