CreateKey returned 6
-
Hi, I am using the following script to write key and values into registry using vbscript. this is my code
strComputer = "."Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")keyPath = "*\shellex\ContextMenuHandlers\WWBuildShell64Ext"Return = oReg.CreateKey HKEY_CLASSES_ROOT ,keyPath If (Return = 0) And (Err.Number = 0) Then Wscript.Echo "HKEY_LOCAL_MACHINE\Software\MyKey\MySubKey created"Else Wscript.Echo "CreateKey failed. Error = " & Err.NumberEnd If
It is retuning 6. What does it mean? how to correct it? Please help me. Thanks
-
Hi, I am using the following script to write key and values into registry using vbscript. this is my code
strComputer = "."Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")keyPath = "*\shellex\ContextMenuHandlers\WWBuildShell64Ext"Return = oReg.CreateKey HKEY_CLASSES_ROOT ,keyPath If (Return = 0) And (Err.Number = 0) Then Wscript.Echo "HKEY_LOCAL_MACHINE\Software\MyKey\MySubKey created"Else Wscript.Echo "CreateKey failed. Error = " & Err.NumberEnd If
It is retuning 6. What does it mean? how to correct it? Please help me. Thanks
About 10 seconds worth of Googling reveals that the return code 6 means that a handle is invalid. That would probably mean that you didn't define a value for HKEY_CLASSES_ROOT, which would put it's default value to 0. I don't think that's valid, so another Google for "VBScript HKEY_CLASSES_ROOT" says the declaration for it should be:
Const HKEY_CLASSES_ROOT= &H80000000
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008