i want create Addon read reg and run file

Talk about add-ons and extension development.
Post Reply
emadalden
Posts: 8
Joined: April 9th, 2015, 5:50 am

i want create Addon read reg and run file

Post by emadalden »

create Addon read Windows registry and run file and disable Download Dialog

using on newer version Mozilla Firefox


thanks
Last edited by emadalden on April 9th, 2015, 6:31 am, edited 2 times in total.
User avatar
LIMPET235
Moderator
Posts: 39956
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Re: i want create Addon read reg and run file

Post by LIMPET235 »

Moving to Extension Dev...
[Ancient Amateur Astronomer.]
Win-10-H/64 bit/500G SSD/16 Gig Ram/450Watt PSU/350WattUPS/Firefox-115.0.2/T-bird-115.3.2./SnagIt-v10.0.1/MWP-7.12.125.

(Always choose the "Custom" Install.)
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: i want create Addon read reg and run file

Post by Noitidart »

easily done

this here shows how to read registry; https://ask.mozilla.org/question/1422/hashstring/

download without showing download use Downloads.jsm https://developer.mozilla.org/en-US/doc ... oadManager

what exactly are you trying to do?
emadalden
Posts: 8
Joined: April 9th, 2015, 5:50 am

Re: i want create Addon read reg and run file

Post by emadalden »

Noitidart wrote:easily done

this here shows how to read registry; https://ask.mozilla.org/question/1422/hashstring/

download without showing download use Downloads.jsm https://developer.mozilla.org/en-US/doc ... oadManager

what exactly are you trying to do?



i want read reg direct file .exe and run this file and command
Contains url download file
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: i want create Addon read reg and run file

Post by Noitidart »

to run a file do so with nsIProcess see this example: https://gist.github.com/Noitidart/f605f648cab355e56648

and this is a copy paste of the read registry:

Code: Select all

var _cache_getAllFxBuilds;
function getAllFxBuilds() {
   // currently win7+ only
   
   if (!winStuff.isWin7) {
      throw new Error(['os-unsupported', OS.Constants.Sys.Name]);
   } else {
      if (!_cache_getAllFxBuilds) {
         var wrk = Cc['@mozilla.org/windows-registry-key;1'].createInstance(Components.interfaces.nsIWindowsRegKey);
         var keypath = 'Software\\Mozilla\\' + Services.appinfo.name + '\\TaskBarIDs'; //Services.appinfo.name == appInfo->GetName(appName) // http://mxr.mozilla.org/comm-central/source/mozilla/widget/windows/WinTaskbar.cpp#284
         try {
           wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE, keypath, wrk.ACCESS_READ);
         } catch(ex) {
           //console.warn(ex)
           if (ex.message != 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWindowsRegKey.open]') {
            throw ex;
           } else {
            try {
              wrk.open(wrk.ROOT_KEY_CURRENT_USER, keypath, wrk.ACCESS_READ);
            } catch (ex) {
              throw ex;
            }
           }
         }
         //list children
         var numVals = wrk.valueCount;
         for (var i=0; i<numVals; i++) {
           var keyval = {
            Name: wrk.getValueName(i)
           };
           keyval.Type = wrk.getValueType(keyval.Name);
           keyval.TypeStr = win_RegTypeStr_from_RegTypeInt(keyval.Type);
           if (keyval.Type == 0) {
            throw new Error('keyval.Type is `0` I have no idea how to read this value keyval.Type == `' + keyval.Type + '` and keyval. Name == `' + keyval.Name + '`');   
           }
           keyval.Value = wrk['read' + keyval.TypeStr + 'Value'](keyval.Name)
           //console.log('keyval:', uneval(keyval), keyval);
           _cache_getAllFxBuilds.push(keyval);
         }
         wrk.close();
      }
      
      return _cache_getAllFxBuilds;
   }
}


function win_RegTypeStr_from_RegTypeInt(int) {
  if (int == 1) {
    return 'String';
  } else if (int == 3) {
    return 'Binary';
  } else if (int == 4) {
    return 'Int';
  } else if (int == 11) {
    return 'Int64';
  } else if (int == 0) {
    return 'NONE';
  } else {
    throw new Error('keyval.Type is not any of the expected values of 0, 2, 3, 4, or 11 so am now confused. keyval.Type == `' + int + '`');
  }
}
emadalden
Posts: 8
Joined: April 9th, 2015, 5:50 am

Re: i want create Addon read reg and run file

Post by emadalden »

this Code "Disable download" be correct

Code: Select all

Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar)
                   .registerFactory(Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}"), "", "@mozilla.org/transfer;1", null);



Is there a Code "Run file .exe" smaller than this https://gist.github.com/Noitidart/f605f648cab355e56648
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: i want create Addon read reg and run file

Post by Noitidart »

emadalden wrote:this Code "Disable download" be correct

Code: Select all

Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar)
                   .registerFactory(Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}"), "", "@mozilla.org/transfer;1", null);



Is there a Code "Run file .exe" smaller than this https://gist.github.com/Noitidart/f605f648cab355e56648

Yes here you go: https://gist.github.com/yajd/105f4f8df3 ... sync-js-L1
emadalden
Posts: 8
Joined: April 9th, 2015, 5:50 am

Re: i want create Addon read reg and run file

Post by emadalden »



Code: Select all

   

// get reg

var downloaderVersion = "";
const nsIWindowsRegKey = Components.interfaces.nsIWindowsRegKey;
   var wrk = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
   wrk.open(wrk.ROOT_KEY_CURRENT_USER,"SOFTWARE",wrk.ACCESS_READ);
   if (wrk.hasChild("Speed"))
  {
      var sbSubkey = wrk.openChild("Speed", wrk.ACCESS_READ);
      var vdConverter = "Download ";
      if (sbSubkey.hasChild(vdConverter))
    {

         var vcSubkey = sbSubkey.openChild(vdConverter, wrk.ACCESS_READ);
         if (vcSubkey.hasValue("LWV"))
      {
            downloaderVersion = vcSubkey.readStringValue("LWV");
         }
         vcSubkey.close();
      }
      sbSubkey.close();
   }
   wrk.close();
prompts.alert(null, "emad",downloaderVersion);   


/// run file

var file = Components.classes["@mozilla.org/file/local;1"]
      .createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("C:\\LMGS.exe");

//file.launch();
var process = Components.classes["@mozilla.org/process/util;1"]
              .createInstance(Components.interfaces.nsIProcess);
   process.init(file);


var s1 ="n";
      var arguments = [s1] ;
process.run(false, arguments, arguments.length);



thanks ,but operation Run only on Developer Edition
Noitidart
Posts: 1168
Joined: September 16th, 2007, 8:01 am

Re: i want create Addon read reg and run file

Post by Noitidart »

That shouldn't be the case that should run from all channels.
emadalden
Posts: 8
Joined: April 9th, 2015, 5:50 am

Re: i want create Addon read reg and run file

Post by emadalden »

Noitidart wrote:That shouldn't be the case that should run from all channels.


help me please , how to run on Mozilla Firefox
Post Reply