tags:

views:

74

answers:

2
var localFile = Components.classes["@mozilla.org/filelocal;1"].createInstance(Components.interfaces.nsILocalFile);
localFile.initWithPath("C:\Windows\system32\cmd.exe");
var process = Components.classes["@mozilla.org/processutil;1"].createInstance(Components.interfaces.nsIProcess);
process.init(localFile);
var args=null;
process.run(false, args, args.length);

I am using Firefox/3.6. The above code is not getting invoked. I wanna that is there any need to include something in my code to invoke these components. In my browser these XPComponent are available as i checked using **

XPComViewer.

Plzzz Reply ASAP.

Regards, rAHUL......

+1  A: 
  1. Set up the development environment and check the Error Console. That would give you hints as to what your problem is.
  2. Just copy the snippet from https://developer.mozilla.org/en/Code_snippets/Running_applications#Using_nsIProcess, that will give you correct code to get the necessary services.
  3. Two less obvious errors are that a '\' has a special meaning and needs to be escaped (as in the linked snippet) and args=null won't work because you try to get its length a line later. You want args=[].

Finally, you didn't say where you're trying to run this from.

Nickolay
i did like this only but i am getting the following error:Error: Permission denied for <http://localhost:8080> to get property XPCComponents.classesSource File: http://localhost:8080/ViewerSoln/Line: 60i am trying this on Firefox 2.0 and 3.6 both. its windows environment. please suggest me something ASAP.Thank you,Rahul.
Rahul
@Rahul: You can't do anything that requires extended privileges from content pages. The specific solution you should use depends on the specifics of your situation. Please search for previous discussions. E.g. http://stackoverflow.com/questions/127693/firefox-xpcom-component-permission-denied-to-call-method-unnamedclass/146820#146820
Nickolay
A: 

i did like this only but i am getting the following error:

Error: Permission denied for http://localhost:8080 to get property XPCComponents.classes Source File: localhost:8080/ViewerSoln Line: 60

i am trying this on Firefox 2.0 and 3.6 both. its windows environment. please suggest me something ASAP.

Thank you, Rahul.

Rahul