Mozilla : "Error: Permission denied for <localhost:8080> to get property XPCComponent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahuljaiswal1987
    New Member
    • Apr 2010
    • 23

    #1

    Mozilla : "Error: Permission denied for <localhost:8080> to get property XPCComponent

    Code:
    var path = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get('ProfD', Components.interfaces.nsIFile).path;
    var localFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
    localFile.initWithPath("C:\\Windows\\system32\\cmd.exe");
    localFile.launch();
    var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
    process.init(localFile);
    var args-null;
    process.run(false, args, args.length);


    I am trying this piece of code in Mozilla 2.0 and 3.6 both. But in both it is giving error:

    "Error: Permission denied for <localhost:8080 > to get property XPCComponents.c lasses"

    in line 1 only. Please suggest me something in this regard.


    Regards,
    Rahul
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    you will need enhanced privileges for such code to execute ... call the following before your code:

    Code:
    netscape.security.PrivilegeManager.enablePrivilege(
        'UniversalXPConnect'
    );
    kind regards

    Comment

    • rahuljaiswal1987
      New Member
      • Apr 2010
      • 23

      #3
      Hi Gits,

      Now i am getiing this error.

      Error: uncaught exception: A script from "http://localhost:8080" was denied UniversalXPConn ect privileges.


      What to do??

      Comment

      • rahuljaiswal1987
        New Member
        • Apr 2010
        • 23

        #4
        Hi Gits,

        I got the solution. Jus type "about:config" in address bar and you'll get a list of preferences. Now search for "signed.applets. codebase_princi pal_support" in this list and toggle its value to "true". Now everything will work rosy.

        Thanks for your replies
        rAHUL

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          that's of course a preliminary to execute those code .... :)

          Comment

          Working...