need a script which deletes a certain registry key that has subkeys

Discussion in 'Scripting' started by Spin, Nov 13, 2005.

  1. Spin

    Spin Guest

    Experts,

    I need a script which first deletes a certain registry key that has subkeys,
    then adds a new key into it's place. I am an administrator of this
    computer. Running Windows Server 2003 SP1. Path to key is below. The key
    name is MSExchangeDSAccess.

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchangeDSAccess

    While I know how to import/merge a new key silently onto a computer using
    regedit /s, I do not know how to delete a just specific key only (which is
    the first part of my script.

    Please do not suggest to simply "merge" a new key on top of the existing
    key. Even though I am an adminstrator of the system this doesn't work.
    Merging the new key on top of the old still leaves two subkeys behind the
    old one had. So what I am now looking to do is like I said at the
    beginning, make a script which first deletes a certain registry key that has
    subkeys, then adds a new key into it's place.
     
    Spin, Nov 13, 2005
    #1
    1. Advertisements

  2. You can use the REG command that has a delete option :

    REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

    KeyName [\\Machine\]FullKey
    Machine Name of remote machine - omitting defaults to the current
    machine
    Only HKLM and HKU are available on remote machines
    FullKey ROOTKEY\SubKey
    ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
    SubKey The full name of a registry key under the selected ROOTKEY
    ValueName The value name, under the selected Key, to delete
    When omitted, all subkeys and values under the Key are deleted
    /ve delete the value of empty value name <no name>
    /va delete all values under this key
    /f Forces the deletion without propmt

    gr /\/\o\/\/
     
    /\\/\\o\\/\\/, Nov 13, 2005
    #2
    1. Advertisements

  3. Spin

    Spin Guest

    That worked! You 'da man!

    --
    Spin

     
    Spin, Nov 13, 2005
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.