I'm trying to copy a registry key and its values to another key.
I can get the value of type REG_EXPAND_SZ keys but it looks like the string
value is expanded in the process. As I am trying to copy from one key to
another I would like to get the unexanded value. Here briefly, is how I'm
getting the key:

Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")

oReg.GetExpandedStringValue hive,keypath,name,strValue
StdOut.WriteLine " " & strValue


Printing strValue out shows the expanded value.
Where the content of the value "name" might be "This is the path: %PATH%"
the actual printed value will show the expanded value of %PATH%.

I want to copy that value as is to the new key:name. Is there a way to get
the unexpanded value? I tried using oReg.GetStringValue but it operated the
same way as the oReg.GetExpandedStringValue function.

Any help would be appreciated

Re: How do I copy REG_EXPAND_SZ keys without expanding? by Ayush

Ayush
Wed Feb 28 19:18:21 CST 2007

Richard Winks wrote ::
> I'm trying to copy a registry key and its values to another key.
> I can get the value of type REG_EXPAND_SZ keys but it looks like the string
> value is expanded in the process. As I am trying to copy from one key to
> another I would like to get the unexanded value.


Use RegRead method WshShell :

Set ws = CreateObject("WScript.Shell")
vData = ws.RegRead("HKCR\String")

msgbox vData

`````````
You can specify a key-name by ending strName with a final backslash. Do not
include a final backslash to specify a value-name. When you specify a
key-name (as opposed to a value-name), RegRead returns the default value.

``````````




Good Luck, Ayush.
--
Scripting Home : http://snipurl.com/Scripting_Home