I'm currently attempting to write Javascript in order to read and write from the Windows registry in an HTA file. Here is the current code I am using to write:
writeInRegistry = function (sRegEntry, sRegValue) {
Regpath = "HKEY_LOCAL_MACHINE\\Software\\CompanyName\\CompanyValues\\" + sRegEntry;
try {
var oWSS = new ActiveXObject("WScript.Shell");
oWSS.RegWrite(Regpath, sRegValue, "REG_DWORD");
oWSS = null;
} catch (e) {
alert('Error trying to write "' + sRegValue + '" to registry entry "' + sRegEntry + '"');
}
}
Unfortunately when I check the values in regedit, they remain unchanged. I made sure to double check that the registry path is exactly the same as I have it in javascript. It doesn't return an error, so I'm assuming the path is correct.
I also attempted to try
var oWSS = WScript.CreateObject("WScript.Shell");
as referred to in this msdn page, instead of
var oWSS = new ActiveXObject("WScript.Shell");
but that just gave me more problems.
Any help is appreciated! Thanks!