Forum Discussion

Yogesh_C's avatar
Yogesh_C
New Contributor
9 years ago

How to rename Registry (Subsection)?

A Section object is returned by the Registry method of the Storages object.

https://support.smartbear.com/viewarticle/85046/

 

I understand how I can create/modify an 'Option' (using SetOption Method).

 

But how can I rename existing 'Subsection'?

 

I am trying to temporarily modify a Registry SubSection (by appending '_old') to setup condition for particular test.

 

Any help will be appreciated.

  • The Storages object does not support renaming registry keys. You'll need to delete the old key and create a new one.

     

    A possible way is to shell out to reg.exe to copy the key recursively then delete the old key:

    // JScript / JavaScript
    var oShell = Sys.OleObject("WScript.Shell");
    oShell.Run("reg copy HKCU\\MyKey HKCU\\MyKey_old /s /f", 0, true);
    oShell.Run("reg delete HKCU\\MyKey /f", 0, true);
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    The Storages object does not support renaming registry keys. You'll need to delete the old key and create a new one.

     

    A possible way is to shell out to reg.exe to copy the key recursively then delete the old key:

    // JScript / JavaScript
    var oShell = Sys.OleObject("WScript.Shell");
    oShell.Run("reg copy HKCU\\MyKey HKCU\\MyKey_old /s /f", 0, true);
    oShell.Run("reg delete HKCU\\MyKey /f", 0, true);