|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
WSH Problem
Okay anyone got an explanation?
Code:
regtest.vbs
strRegValue = "HKLM\Software\Microsoft\Windows\CurrentVersion\ProductID"
Set WshShell = WScript.CreateObject("WScript.Shell")
strPID = WshShell.RegRead (strRegValue)
Wscript.Echo strPID
WshShell.RegDelete 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 05:37 AM. |
|
#2
|
|||
|
|||
|
Hi Nilpo,
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. |
|
#3
|
||||
|
||||
|
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 02:05 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > WSH Problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|