2

I'm trying to build a Firefox add-on which lets you create executable files which can be associated with a default program or added to the "Open With" list and possess its own icon.

I was hoping to avoid having the add-on compile files into exes, but...

  1. It does not seem batch files can have their own icons.
  2. Although one can pass batch instructions to cmd.exe via shortcut (and shortcuts can have their own icons) and a shortcut can even accept arguments (as in dropping files onto it), one apparently cannot add shortcuts to the "Open with" menu (the Open With dialog treats the shortcut as equivalent to the referenced executable, in this case, .exe, and without the extra parameters).

So, I'd like to know what other approaches might be available to me for building executables (or something that really functions like an executable) in a simple and transparent manner? I am leaning toward packaging an open-source batch-to-exe converter like http://sourceforge.net/projects/bat2exe/ (though I'd really hope to find one which itself can be controlled via command line) so I can build a batch file programmatically and then turn it into a full-blown executable with icon.

UPDATE

The primary reason I want to do this is for the sake of https://github.com/brettz9/webappfind . WebAppFind lets you open desktop files (while you are on your desktop) into web applications and currently comes with pre-built executables which can be associated with a given file extension (to work with Open With or as a default handler). These executables will be used to call Firefox (and my add-on, WebAppFind) with certain flags that allow WebAppFind to open the file in a web app (as determined by other factors like a filetypes.json file in the same directory as the file or a previously registered protocol handler correlated to the file extension, as explained at the repo).

However, what I cannot pre-build into the executable are all possible configuration directive combinations a user might wish to supply to the add-on or, more importantly, the specific Firefox profile in which they wish the app (with desktop file) to load. The ability to open a web app in any profile can allow for web apps to work more like executables--they get their own icon in the task bar, they don't have to force the user to load a bunch of tabs or add-ons if, e.g., they just want to have open in a separate process their local HTML file in a JavaScript-based WYSIWYG HTML editor or their SVG file in an SVG-edit web app (And I also don't want users to have to go through the trouble of associating an icon with the exe manually.)

  • 2
    Sounds like you are trying to open up a gaping security hole. – James Anderson Jan 14 '14 at 1:56
  • I had a thought about point #2. I used to make additions to the context menu manually via regedit - just adding some "folders", keys, and values. So if you're not terribly stuck on "Open With" but rather go straight to a custom command, you might very well be able to avoid the limitations of "Open With". All that being said, I definitely agree about the security hole..! – J Trana Jan 14 '14 at 5:04
  • As far as security, how is this opening a security hole? I'm not exposing the functionality to websites... Firefox add-ons already have the ability to run processes--I'm just letting users take advantage of it themselves. – Brett Zamir Jan 14 '14 at 5:26
  • 1
    It would probably be easier to understand and answer the question if you gave an example use-case for this addon? – Carson63000 Jan 14 '14 at 7:13
  • 1
    Assuming you are not trying to implement a virus or "trojan horse", why not just preparing the exe file beforehand, and embed the binary data of the exe file in the source code of your addon? Later, your addon writes the binary data to a file named "YourProg.exe" again. As an alternative, if you really need to generate the source code dynamically, on most modern Windows system you will find a C# command line compiler installed with the .NET framework (see msdn.microsoft.com/en-us/library/ms379563%28v=vs.80%29.aspx) – Doc Brown Jan 14 '14 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.