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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NT Registry control

Status
Not open for further replies.

munro69

Programmer
Joined
Jan 22, 2001
Messages
5
Location
GB
I am looking for some asp code (javascript) which allows the web interface to edit entries in the NT registry. Any ideas where I could get this...?
Thank you
:)
 
Pretty easy with WSH (must install it from Microsoft's site if you don't have at least NT 4 SP4 (or maybe it was 5))...

Code:
<%
@
Code:
Language=&quot;JScript&quot;%>
<%
	var oWSH = new ActiveXObject(&quot;WScript.Shell&quot;);
	var regKey = &quot;HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Test&quot;;
	Response.Write(&quot;Current test key: &quot; + regKey + &quot;<br><br>&quot;);

	try {
		oWSH.RegWrite(regKey, &quot;myString&quot;, &quot;REG_SZ&quot;);
	}
	catch(e) {
		Response.Write(&quot;ERROR: Writing to &quot; + regKey + &quot;<br>Did you set the security permissions to allow IUSR to read/write?&quot;);
	}
	finally {
		Response.Write(&quot;Wrote to &quot; + regKey + &quot;<br>&quot;);
	}

	try {
		var regVal = oWSH.RegRead(regKey);
	}
	catch (e) {
		Response.Write(&quot;Key doesn't exist!<br>&quot;);
	}
	finally {
		if (regVal == regKey) {
			Response.Write(&quot;Value is NULL<br>&quot;);
		}
		else if (regVal == undefined) {
			Response.Write(&quot;Key didn't exist. No value&quot;);
		}
		else {
			Response.Write(&quot;Value = &quot; + regVal + &quot;<br>&quot;);
		}
	}
	
	try {	
		oWSH.RegDelete(regKey);
	}
	catch (e) {
		Response.Write(&quot;The key &quot; + regKey + &quot; could not be removed.<br>&quot;);
	}
	finally {
		Response.Write(&quot;The key &quot; + regKey + &quot; has been removed.<br>&quot;);
	}
%>

Hope it helps, Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top