August 12th, 2006, 03:08 AM
Okay anyone got an explanation?
strRegValue = "HKLM\Software\Microsoft\Windows\CurrentVersion\ProductID"
Set WshShell = WScript.CreateObject("WScript.Shell")
strPID = WshShell.RegRead (strRegValue)
Wscript.Echo "The registry value has been deleted."
WshShell.RegWrite strRegValue, strPID
Wscript.Echo "The registry value has been written back."
Why am I recieving an error when I use the VBScript syntax for the RegRead method (without parenthesis)? The RegWrite and RegDelete methods both work properly, but the RegRead method won't execute without parenthesis.
Last edited by nilpo; August 12th, 2006 at 06:37 AM.
August 16th, 2006, 06:06 PM
The reason is because the RegWrite and RegDelete routines are Sub routines and are not returning a value.
The RegRead routine is a Function and does return a value.
Vbscript syntax requires that a function always is followed by parenthesis even if no value is passed into the function.
I think this dates to the original coding syntax defined for vbscript.
August 17th, 2006, 03:03 PM
RegRead IS a function? That's interesting. It does make sense considering it returns the value it finds in the registry. I wasn't aware of that. Thanks for the heads up.
Last edited by nilpo; August 17th, 2006 at 03:05 PM.