...

View Full Version : need help with WScript.Shell in a .hta file



babelfish
08-23-2004, 12:15 PM
hi peeps! :thumbsup:

i need to read the registry to see if content adviser is enabled..

the problem is that i get an error if there is nothing in that key :(

alert (WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\policies\\Ratings"));

if that key has a value thats ok - but if not i get an error saying it cant be read... i just need to set a variable to yes/no depending on whether its blank or not... it seems stupid to me. surely if its blank then just return an empty string?!?!?! HELP plz :confused:

rsci
08-23-2004, 03:05 PM
Haven't worked with registry keys but have you tried...

if (regkey){alert(regkey)}

babelfish
08-23-2004, 04:33 PM
nope :(

the problem is if you try and read a key that has no value you get the error... its stupid logic really...

i get a similar thing when trying to delete registry entries... if there isnt a value it wont let you delete them (i.e. ignore them if not there and delete if they are!) so i have to create a blank entry then delete it... arghhh @ micro$lop :rolleyes:

jbot
08-23-2004, 05:05 PM
arghhh @ micro$lop

hey, don't dis the mighty microsoft coders ... see how helpful they are these days, working extra hours to give us yet another free update to their software. how many other companies do you know that release new versions of their software every so often.

sloppy indeed, just dilligent, i say. ;)

babelfish
08-23-2004, 05:07 PM
fair point... although they arent technically giving more as fixing really.... :)

although look at ahead etc for upgrading the likes of nero etc..

jbot
08-23-2004, 10:13 PM
fair point... although they arent technically giving more as fixing really

i was actually being sarcastic.

of course, their code is sloppy. SP2 is witness to that. no sooner has it been released, but there are already a fresh batch of security issues discovered.

the problem with Windows, however, is not necessarily the people that work on it, but the man at the healm. it's essentially Bill Gates' greed which stops them from building a new OS from scratch, not just building on the same mistakes as before. i should know, i work a firm which has done the same thing. when will they ever learn??

anyway, we digress ... :p

glenngv
08-24-2004, 06:19 AM
alert (WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\policies\\Ratings"));

Try putting it inside the try-catch block.


var rating = "";
try {
rating = WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\policies\\Ratings");
}
catch(e){
//ignore error, rating is already initialized to empty
}
if (contentAdv!=""){
alert("Content Advisor has a rating of: " + contentAdv);
}
else {
alert("No rating.");
}

babelfish
08-24-2004, 10:11 AM
arghhhhhhhh... i was just going to poast that i fixed it... why didnt i get an email from this system? :(




try { //checks to see if content advisor has already been removed - if not you need to restart IE to take affect
var key = WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\policies\\Ratings\\.Default\\Enabled");
}

catch (e) {
/*
if (e != 0) {
alert("Error: " + e + " Entry doesn't exists");
}
*/
}

if (key=="1") {
alert("When this is fixed you will need to restart ALL instances of Internet Explorer for changes to take affect");
}



thanks tho m8e... i cant believe how easy this was in the end... it took me about 5 hours of solid exploration till i found this simple solution

thanks tho m8! :thumbsup: :thumbsup: :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum