2
我有我要用來啓動已經安裝在我的電腦如NOTEPAD.EXE
問題程序的插件找到一個外部的程序是,它似乎Firefox不搜索系統路徑,程序即使用Firefox運行在系統PATH
file.initWithPath("c:\\windows\\system32\\notepad.exe");//works
//file.initWithPath("notepad.exe");//does not work
//file.initWithPath("%systemroot%\\notepad.exe");//does not work
問:
是否有將Firefox查找系統中的PATH程序的方式嗎?
這裏是我的完整功能
autoStartNotepad:function()
{
// create an nsILocalFile for the executable
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("notepad.exe");//does not work
//but file.initWithPath("c:\\windows\\system32\\notepad.exe");//works
// create an nsIProcess
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
var args = [];
process.run(false, args, args.length);
}