Remove a Registry Key

  • I did not know about the ‘-’ in front of the key… if that works that’d be great!..

    I’m trying to remove a regkey during postdeployment; because recreating the image because of one key is kind of ambiguous. I’ll check out your advice, will post back later!

  • Developer

    Since you are trying to remove a key. You can use the command line to do so.
    reg delete "HKCU\The\Registry\To\Delete" /f

    OR if you have a .reg file open the file and put a - before the HKEY portion…
    like so and do a reg import for that file.

    I use a hidden flag.txt and a script that will look for the flag.txt file, if not found, it will run some scripts similar to what you have described and then the next time the user logs in, if the flag.txt is present (which it should be, the script copies the file to where it needs to be.) then the script won’t run again.
    I do this in cases where I need to update the registry values for that user only one time. I.E. I set the taskbar, and Start menu to a specific layout. I don’t want to do this on every log in, and it requires registry edits. So I do it once per user when flag.txt isn’t present.

    Another option would be to create the script, use a snap in as a deployment after imaging completes. I don’t know exactly what you are trying to accomplish, but I am certain it can be done.

    Hope this helps!

  • Senior Developer

    Of course it’s possible. I couldn’t tell you how to do it, but I know it can be done.

Log in to reply