I would like to read a registry value in my script and assign it to a variable but I have no clue when it comes to Jscript. The script has two functions with embeded that are called with onclick:
<html>
<head>
<script language="javascript">
<!--
var value;
var Shell;
var cicserver;
Shell = new ActiveXObject("WScript.Shell");
value = Shell.RegRead("HKLMSoftwareInteractive IntelligenceEICNotifier");
if value = "servername1"
{ cicserver = "servername1"
}
else
{ cicserver = "servername2"
}
This is not shell scripting it's web scripting. YOu cannot read teh registry from aa web page. You need to use a local script; either vbs or jscript. YOu can also use an HTA.
Put this in a file with a .js extension and run it at a command prompt.
var Shell = new ActiveXObject("WScript.Shell");
var value = Shell.RegRead("HKLMSoftwareInteractive IntelligenceEICNotifier");
if (value == "servername1"){
var cicserver = "servername1"
}else{
var cicserver = "servername2"
}
WScript.Echo( cicserver
<html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 2009">
<title>Document Title</title>
</head>
<script language="jscript">
var key = "HKLMSoftwareInteractive IntelligenceEICNotifier";
function doit(){
var t = document.getElementById("out");
var Shell = new ActiveXObject("WScript.Shell");
var value = Shell.RegRead(key);
if (value == "servername1"){
t.innerText = "servername1"
}else{
t.innerText = "servername2"
}
return false;
}
</script>
<body>
<input type="button" value="click" id="getit" onclick="js:doit()"/>
<input type="text" id="out" />
</body>
</html>
Must be run locally from an HTA file or with warnings from an HTML file.
Due to cross-domian restrictions it will probably not run on IE from a web server. To do that you would need to use ASP.NET and some fairly sophisticated techniques to get the registry info.