RegCreateKey error 87

Started by hienpham, July 21, 2015, 01:57:44 AM

Previous topic - Next topic

hienpham

Hi,
   I have a WinBatch script that creates some registry on HKEY_USERS\.DEFAULT with RegCreateKey.
   I do not have any problem if I use (with UserKey = .DEFAULT):
      Regkey = RegCreateKey(@REGUSERS,UserKey:"\Software\Microsoft\Windows\CurrentVersion\Internet Settings",0)
             (I was able to create the corresponding registry key)
but just replace the above with
      Regkey = RegCreateKey(@REGUSERS,UserKey:"Software\Policies\Microsoft\Windows",0)

I got "RegCreateKey error 87"

I run both test with the same Admin privilege, same condition, same system (Windows 8 I can duplicate this problem on Win 7) .

Any suggestion will be very welcome.

Thanks

td

First, you are missing a backslash(\) in the second parameter of the second call to the RegCreateKey function. 
Code (winbatch) Select

; This
Regkey = RegCreateKey(@REGUSERS,UserKey:"Software\Policies\Microsoft\Windows",0)

;Should be
Regkey = RegCreateKey(@REGUSERS,UserKey:"\Software\Policies\Microsoft\Windows",0)


Secondly, when WinBatch includes a numeric error number, it is a system error.  You can find the text associated with system errors in the Tech Database.  You can even find a script that allows you to retrieve the text for systems errors from The System.  In your case, error 87's associated text is amazingly 'The parameter is incorrect.'
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

hienpham

Thanks so much TD, I was crazy not to see that typo mistake.
Have a GREAT day!