Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. CreateKey returned 6

CreateKey returned 6

Scheduled Pinned Locked Moved Visual Basic
helpwindows-admintoolstutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    subramanyeswari
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • S subramanyeswari

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups