<script>
function hello () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("D:\program files\foobar2000\foobar2000.exe");
file.launch();
}
</script>
function hello () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("D:\program files\foobar2000\foobar2000.exe");
file.launch();
}
</script>
上面的代码,执行未加参数的程序;下面的代码,执行添加了参数的程序。
function hello() {
var oURL = "www.baidu.com";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var process = Components.classes[’@mozilla.org/process/util;1’].getService(Components.interfaces.nsIProcess);
var targetFile = Components.classes[’@mozilla.org/file/local;1’].createInstance(Components.interfaces.nsILocalFile);
targetFile.initWithPath("D:\temp\1.exe");
process.init(targetFile);
var arguments = [oURL]; //arguments参数必须是数组,否则下面语句不执行
process.run(false, arguments, arguments.length,{});
}
var oURL = "www.baidu.com";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var process = Components.classes[’@mozilla.org/process/util;1’].getService(Components.interfaces.nsIProcess);
var targetFile = Components.classes[’@mozilla.org/file/local;1’].createInstance(Components.interfaces.nsILocalFile);
targetFile.initWithPath("D:\temp\1.exe");
process.init(targetFile);
var arguments = [oURL]; //arguments参数必须是数组,否则下面语句不执行
process.run(false, arguments, arguments.length,{});
}