1

I have a chrome extension that works with my exe file. I want to deliver just one exe file to my client. I tried converting the zip file into hex, but then I get a string with 25 thousand lines. I don't think that's the right way to do it.

How can I deliver my zip file with my exe?

thimo
  • 45
  • 5
  • If it is a Windows application, you can embed it as a resource. [Load resource as byte array programmaticaly in C++](https://stackoverflow.com/q/16527973) – 001 Aug 25 '22 at 20:09
  • 2
    Can you please explain what do you mean by "deliver"? You want your extension to download your exe file, store it somewhere in %APPDATA% or something like that? – Kamil Aug 25 '22 at 20:37
  • Is this allowed in Chrome Store? I mean executing external `exe` by browser extension. – Kamil Aug 25 '22 at 20:46
  • It's not possible to execute an exe with an extension. I want to send the exe to my client but the extension also has to be delivered with the exe. – thimo Aug 25 '22 at 22:04

1 Answers1

0

What you are trying to do is definitely doable, I've seen it being done many times.

If you have MinGW installed, you can use xxd tool that will do the trick for you.

xxd -i your_zip_filename embedded_zip_data.h

Now you simply add #include "embedded_zip_data.h" in your source code and it will be right there in the application data.

Jardel Lucca
  • 1,115
  • 3
  • 10
  • 19
  • How can I upload the zip to a specific path on client computer? – thimo Aug 26 '22 at 15:42
  • @thimo you can simply write the data in `"embedded_zip_data.h"` to a file using `fwrite` in the application. If however your intention is to have the zip file without the need for your customer to run the executable, what you really need is an installer. Then have a look at [this](https://www.makeuseof.com/tag/how-to-make-an-exe-installation-file/) and [this](https://www.maketecheasier.com/create-self-extracting-archives-without-installing-software/). – Jardel Lucca Aug 26 '22 at 17:25
  • Thank you it worked. Any idea how I can extract the zip on client computer? – thimo Aug 29 '22 at 13:14
  • @thimo I suspect it would be a good idea not to zip the files, but simply add them raw in the source code. By this way, you don't need to unzip the files and you can "install" them with `fwrite` only. If however you really need to save space and zip the files, you will probably have to resort to some ZIP library such as [`libzip`](https://libzip.org/). Or you could save the file (using `fwrite`) zipped and call an external application to unzip it from your application. – Jardel Lucca Aug 29 '22 at 19:56
  • I found the tar command. It does it's job. – thimo Aug 30 '22 at 12:10
  • I just read that tar command isn't native. So I have to do something else. What you said sounds good but it's a lot of files. The size is not the problem but I don't want to mannually xxd all the files – thimo Aug 30 '22 at 12:17
  • I see... What about using [`libtar`](https://github.com/tklauser/libtar) then? It can be compiled with Cygwin and it seems easy to use, as in this [example](https://stackoverflow.com/questions/24895219/using-libtar-library-in-c). – Jardel Lucca Aug 30 '22 at 12:47
  • Another possibility would be to write a shell/bash script that, in build time, lists all the files, calls `xxd` and also writes code to import and save them by the application. – Jardel Lucca Aug 31 '22 at 01:08
  • 1
    The 'tar' command is availible in Windows since build 17063 (it was released in 2018). So I don't think it will be a problem. Do you agree? Thanks for your suggestion I will keep that in mind. – thimo Sep 01 '22 at 10:42
  • 1
    @thimo I didn't know about `tar` being available by default. That's cool, using `system()` with the `tar` command and the filename copied with `fwrite` should work I believe! – Jardel Lucca Sep 01 '22 at 13:50