WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: hienpham on July 21, 2015, 01:57:44 AM

Title: RegCreateKey error 87
Post by: hienpham on July 21, 2015, 01:57:44 AM
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
Title: Re: RegCreateKey error 87
Post by: td on July 21, 2015, 06:51:29 AM
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.'
Title: Re: RegCreateKey error 87
Post by: hienpham on July 21, 2015, 11:03:31 AM
Thanks so much TD, I was crazy not to see that typo mistake.
Have a GREAT day!