Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-23-2004, 12:15 PM   PM User | #1
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
need help with WScript.Shell in a .hta file

hi peeps!

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
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Old 08-23-2004, 03:05 PM   PM User | #2
rsci
New Coder

 
Join Date: Aug 2002
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
rsci is an unknown quantity at this point
Haven't worked with registry keys but have you tried...

if (regkey){alert(regkey)}
__________________
Rsci
gojukyokai@earthlink.net
rsci is offline   Reply With Quote
Old 08-23-2004, 04:33 PM   PM User | #3
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
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
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Old 08-23-2004, 05:05 PM   PM User | #4
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
Quote:
Originally Posted by babelfish
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.
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Old 08-23-2004, 05:07 PM   PM User | #5
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
fair point... although they arent technically giving more as fixing really....

although look at ahead etc for upgrading the likes of nero etc..
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Old 08-23-2004, 10:13 PM   PM User | #6
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
Quote:
Originally Posted by babelfish
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 ...
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Old 08-24-2004, 06:19 AM   PM User | #7
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Quote:
Originally Posted by babelfish
alert (WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\policies\\Ratings"));
Try putting it inside the try-catch block.
Code:
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.");
}
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app

Last edited by glenngv; 08-24-2004 at 06:22 AM..
glenngv is offline   Reply With Quote
Old 08-24-2004, 10:11 AM   PM User | #8
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
arghhhhhhhh... i was just going to poast that i fixed it... why didnt i get an email from this system?


Code:
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!
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:21 AM.


Advertisement
Log in to turn off these ads.