quote:
Originally posted by The_Joker
Tried to use this script but with a function to read & write.
Write works great, but reads gives an error.
If I try the Debug.Trace it works, but return doesn't.
(PS. Taken the script from another post, copied and it doesn't work).
code:
function ReadRegistry(key)
{
var Shell = new ActiveXObject("WScript.Shell");
return value = Shell.RegRead(MsgPlus.ScriptRegPath + key);
}
To analyze where the error is in such situations you should lookup what each object exactly will return in its documentation....
If you do that and you look up MsgPlus.ScriptRegPath in the scripting documentation (or you do simply a test with that object alone) you'll see that it returns a registry path.
Now you append the variable "key" to it, in other words you append a string to a path without anything else.... thus there is something missing in between... Think of it as a file and directory:
"C:\Program Files\MSN Messenger" would be the path and "msnmsgr.exe" the file, append the two and you'll get:
"C:\Program Files\MSN Messengermsnmsgr.exe" which is obviously something not correct as there is a "\" missing...
In other words:
Shell.RegRead(MsgPlus.ScriptRegPath + "\\" + key);
note that you need to put a double "\" as it is otherwise interpreted as a literal escape code
So change that in your example and run it again....
The script will again not give the desired result. Why? Because you have other errors. The proper syntax for a "return" statement is:
return <variable>;
and "value = Shell.RegRead(MsgPlus.ScriptRegPath + key)" is not a value but a statement on its own. So either you do:
var value = Shell.RegRead(MsgPlus.ScriptRegPath + key);
return value;
or simply:
return Shell.RegRead(MsgPlus.ScriptRegPath + key);