问题描述
在我的插件中,我是通过以下方式启动Firefox配置文件的:
In my addon I was launching Firefox profiles by doing this:
var exe = FileUtils.getFile('XREExeF', []); //this gives path to executable
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(exe);
var args = ['-P', profName, '-no-remote']; //-new-instance
if (url) {
args.push('about:home');
args.push(url);
}
process.run(false, args, args.length);
因此,这将添加命令行参数并启动它.但是,这导致一些问题.用户想要固定图标,而只是固定另一个firefox.exe
.用户还尝试更改图标.
So this adds command line arguments and launches it. However this leads to some problems. Users want to pin the icon and it just pins another firefox.exe
. Users also try to change the icon.
维基百科说所有操作系统都支持快捷方式: http://en.wikipedia.org/wiki/File_shortcut
Wikipedia says all OS support shortcuts: http://en.wikipedia.org/wiki/File_shortcut
所以我想复制XREExeF
并将其粘贴为快捷方式,然后向其中添加命令行参数.
So I wanted to copy XREExeF
and paste it as a shortcut and then add command line arguments to it.
感谢@nmaier,我现在知道没有跨操作系统的方法.您能告诉我具体的方法吗?
Thanks to @nmaier I now know there is no cross-os method. Can you please show me os specific methods.
推荐答案
Windows
在此示例中,创建的快捷方式将被称为"Mozilla Firef ya",并将打开一个名为"ya ya"的配置文件.
Windows
In this example the shortcut created will be called "Mozilla Firef ya" and will open up a profile named "ya ya".
Cu.import('resource://gre/modules/FileUtils.jsm');
var exe = FileUtils.getFile('XREExeF', []);
var myShortcut = FileUtils.getFile('Desk', ['Mozilla Firef ya.lnk']);
var myShortcutWin = myShortcut.QueryInterface(Ci.nsILocalFileWin);
var myScIcon = new FileUtils.File('C:\\Users\\Noitidart\\Downloads\\amo-puzzle.ico'); //myScIcon must be converted to ico if it isnt an ico
myShortcutWin.setShortcut(exe, null, '-P "ya ya"', 'Launches Mozilla Firefox with "ya ya" Profile', myScIcon);
- 如何转换为ico:
- https://gist.github.com/Noitidart/77006d9201d0e1dfe2be#comment-1291328 (基于 https://stackoverflow.com/a/24270884/1828637 ),这个主要要点也有来自MXR的processIcon函数
- How to convert to ico:
- https://gist.github.com/Noitidart/77006d9201d0e1dfe2be#comment-1291328 (based on https://stackoverflow.com/a/24270884/1828637) this main gist also has a processIcon function taken from MXR
https://stackoverflow.com/a/25516219/1828637
在此处使用AppleScript:"> https://ask.mozilla.org/question/1126/shortcut-created-on-mac-with-osfile-but-cant-get-around-unidentified-developer-error/
Use AppleScript here: https://ask.mozilla.org/question/1126/shortcut-created-on-mac-with-osfile-but-cant-get-around-unidentified-developer-error/
这篇关于复制XREExeF并粘贴为文件快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!