5

I'm working on a project that has a proprietary file format. The project has a large install-necessary program and a smaller viewer that requires no install. I would like to be able to export files from my main application that are 'self opening' .exe's - that is, you can double click the exe and the embedded file will show (this is to make passing around the viewer to people who have NOT installed the main application able to view it - they will only pass around the document).

I'm a little lost on how to do this. My two thoughts that I've been investigating have come to a dead end. They are:

1) Embed the file in the viewer. I can do this manually through Visual Studio, and I've got a working demo of that, but I can't figure out a way to do this on the fly.

2) Create a self-extracting archive that extracts the file and the exe to temp and runs the exe with the file's name on command line. This sounds easy and possible (albeit hacky), but I've run into the issue that archive or install programs don't seem to have the command line necessary to do all that.

Any ideas? I prefer the second because it's easy, but the first because it seems more bullet proof / less hacky.

DanTheMan
  • 3,277
  • 2
  • 21
  • 40
  • 2
    So, if you send 10 documents, you send 10 copies of the viewer? Isn't this worse than sending the viewer once and then just sending documents and using file association to open them? – AntonyW Jun 17 '11 at 15:48
  • 1
    Wouldn't you be better off putting your efforts into exporting to HTML, PDF or some other common file format that can be read by everyone and everything? Or will that just not do? – Tim Rogers Jun 17 '11 at 15:49
  • 2
    @AntonyW: The documents are hundreds of megabytes, the viewer is less than 500KB. A trade I'm willing to make :) – DanTheMan Jun 17 '11 at 15:51
  • Do you realize that this opens a big security hole? Can you rethink your strategy and export your document to a *standard* (more common) file type like PDF or HTML? – Xint0 Jun 17 '11 at 15:52
  • If you want simple, you could make a batch file that will open the document using the reader and instruct the user to run it. But then again, you could just instruct your user to open the file using the reader himself, but seeing as how you want it done automagically from the user's perspective, you're probably assuming they're computer illiterate. –  Jun 17 '11 at 15:53
  • @Tim, @Xint0: Definitely see where you're going, and I'd LOVE to do that, but that's not an option here. It's in the proprietary format, it must stay in the format. Stupid and annoying, yes, but a requirement from 'upstairs'. – DanTheMan Jun 17 '11 at 15:54
  • @badares: We have an install base of thousands, and get a call probably every other day on how to get people on other computers to open these freaking files. I'm doing this out of desperation :) – DanTheMan Jun 17 '11 at 15:56
  • If the problem is how to get people to open the files, then setup a website (or network share) from which users can setup the viewer. – Xint0 Jun 17 '11 at 16:03
  • Xint0 is right. I'm assuming these EXE files might typically get sent about by email, in which case, even if they don't get trapped by the spam filter, you are encouraging users to click on any old EXE that comes their way! Go 'upstairs' and have a word! ;-) – Tim Rogers Jun 17 '11 at 16:03

2 Answers2

3

Using your method (1):

If you are using .NET, you could make your viewer program be one assembly, and your document be another assembly, then use ILMerge or the like to combine them into one final executable.

ILMerge is a commandline program, so you should be able to automate that step.

That way it should be fairly easy to have your customized viewer essentially just "load the other assembly that's with me" and perhaps call a function on the other assembly to get the data.

The only other piece of the puzzle is how to generate the 'document' assembly. I'm not entirely sure of the steps, but it seems like it should be doable.

Perhaps use CMake or similar to generate a VStudio project, and then use MSBuild to build it into an assembly.

jwd
  • 10,837
  • 3
  • 43
  • 67
1

While bundling the exe into the document to make it a self-opening document is a cool idea, I don't think it's the best solution to the problem. The problem is that the documents require a specific viewer that is not readily available. So make the viewer as easy to get as possible.

And that's what Xint0 suggested in the comments. Find a way to make the viewer as readily available as possible. No need to worry about piracy as it's only a viewer for a proprietary format so the only people interested in it will be people who will already have a document they can't open. So post the viewer on your company website and encourage the companies using the full software to post links to the viewer on their websites so that their customers can easily find it.

Corin
  • 2,317
  • 2
  • 32
  • 47
  • Ok, Corin, you get the 'I'll abandon this effort' pick. I was hoping for something easy and solved, but it just doesn't look like that exists. I don't think doing this is a bad idea or a (too severe) security hole, but I'm not willing to come up with something that no one else has tried before. Oh well! – DanTheMan Jun 19 '11 at 13:19
  • Thank you. As I said, I think the self-opening/viewing document is a cool idea. In a way, I'd like to see an implementation of that just because it's cool. However, I still think that getting your viewer distributed is the problem you really need to solve. – Corin Jun 20 '11 at 16:23