Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts

    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

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Haven't worked with registry keys but have you tried...

    if (regkey){alert(regkey)}

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.");
    }
    Last edited by glenngv; 08-24-2004 at 06:22 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •