2010-04-13 45 views
1
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); 

我使用Firefox/3.6。上面的代碼沒有被調用。我想,有沒有必要在我的代碼中包含一些東西來調用這些組件。在我的瀏覽器中,這些XPComponent可用,因爲我使用**檢查**是否有任何需要在我的代碼中包含某些內容來調用這些組件?

XPComViewer。

Plzzz儘快回覆。

問候,拉胡爾......


我不喜歡這隻但我得到以下錯誤:

錯誤:權限拒絕http://localhost:8080來獲得屬性XPCComponents.classes源文件:本地主機:8080/ViewerSoln線:60

我想這在火狐2.0和3.6都。它的Windows環境。請儘快給我一些建議。

謝謝, Rahul。

回答

1
  1. Set up the development environment並檢查錯誤控制檯。這會給你提示你的問題是什麼。
  2. 只需複製https://developer.mozilla.org/en/Code_snippets/Running_applications#Using_nsIProcess中的片段即可獲得正確的代碼以獲得必要的服務。
  3. 兩個不太明顯的錯誤是'\'具有特殊含義,需要轉義(如鏈接片段中所示),並且args=null將不起作用,因爲您稍後嘗試獲取其長度。你想要args=[]

最後,你沒有說你試圖從哪裏運行。

+0

我不喜歡這隻但我得到以下錯誤: 錯誤:權限拒絕來獲得屬性XPCComponents.classes 源文件:http://本地主機:8080/ViewerSoln/ Line:60 我試着在Firefox 2.0和3.6上都這樣做。它的Windows環境。請儘快給我一些建議。 謝謝, Rahul。 – Rahul 2010-04-15 11:26:21

+0

@Rahul:你無法做任何需要來自內容頁面的擴展特權。您應該使用的具體解決方案取決於您的具體情況。請搜索以前的討論。例如。 http://stackoverflow.com/questions/127693/firefox-xpcom-component-permission-denied-to-call-method-unnamedclass/146820#146820 – Nickolay 2010-04-15 13:54:17

相關問題