Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine, if Registry Key exists and then read it

Status
Not open for further replies.

cattys

Technical User
Jul 2, 2001
19
0
0
DE
Hi,

I have following adapted code from this forum (search for "regdelete")

condition: Intranet, without security confirmation required

<script type=&quot;text/javascript&quot;>
[ignore]
<!--
// user, node, loc, script;
function write_params() {
var Shell = new ActiveXObject(&quot;WScript.Shell&quot;);
var RegistryKey = new Array (&quot;user&quot;, &quot;node&quot;, &quot;script&quot;, &quot;loc&quot;);
var status;
var element;
var key
for (var i = 0; i <= 3; i++) {
element = eval(&quot;document.params.&quot; + RegistryKey);
key = &quot;HKLM\\censored\\&quot;+RegistryKey
status = KeyExists(Shell, key);
if (status) {

element.value = Shell.RegRead(&quot;HKLM\\censored\\&quot;+RegistryKey);
document.write(element.value);
} else {
alert(key + &quot;: key with this name not existent&quot;);
}
}



//var user = Shell.RegRead(&quot;HKLM\\censored\\user&quot;);
//var node = Shell.RegRead(&quot;HKLM\\censored\\node&quot;);
//var script = Shell.RegRead(&quot;HKLM\\censored\\script&quot;);
//var loc = Shell.RegRead(&quot;HKLM\\censored\\loc&quot;);
//document.write(user + &quot;, &quot; + node + &quot;, &quot; + script + &quot;, &quot; + loc)
}

function KeyExists(obj, key) {
var ttkey
try {
ttkey=obj.RegRead(key);
}
catch(e) {
if (e !=0)
return false;
}
return true;
}
-->
</script>
</head>
<body>
<form name=&quot;params&quot; action=&quot;sge_questions&quot; Method=&quot;POST&quot;>
<input type=&quot;hidden&quot; name=&quot;user&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;node&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;script&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;loc&quot; value=&quot;&quot;>
<script type=&quot;text/javascript&quot;>
write_params();
</script>
....
[/ignore]

It just doesn't work.
It gets into an endless loop, if it doesnt find the key.
The variant with reading the keys directly works, but it must not give out any errors, if the script fails. (security issue)

I wopuld appreciate any help or hints :)

Thanks in advance,
cattys

 
On my system (IE6) it simply pops up 4 messages about the 4 keys not being there.

Other than that it works and does not go into any infinite loops for me.

Is this how it's supposed to work or is there more to it?
 
Well...
it actually was my browser, since it had made Dr. Watson appear for IE, I should have reinstalled my sys.
On my collegues' and my other computers it works just fine.

Thanks for the thinking impulse :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top