Click here to Skip to main content
15,886,821 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I would like to create a self extracting archive for windows that will extract files to a temporary folder and then run the extracted startup script, how would I go about doing this?

Note:
I would like to use completely native win32 c++ because the whole point of this is to get around having to download multiple files.

-Jordan
Posted

This problem is neither new nor unique. I would try to search for an existing free solution. What about trying 7z sfx? http://sourceforge.net/projects/s-zipsfxbuilder/?source=dlp[^]
Some sfx decompressors have a "run command after extract" option and some sfx builders have an option to "auto extract to temp folder" and "delete temp folder after command execution" option.
 
Share this answer
 
Comments
Sicppy 26-Jul-13 8:22am    
It is, both new, and unique, im not looking for a pre-made resource, im trying to make my own, self extracting hard drive utility
pasztorpisti 26-Jul-13 8:43am    
Why would it be better to use your own extractor? Do you want a solution or just some fun writing the 1000th sfx solution? :-)
Sicppy 26-Jul-13 11:16am    
Im doing this for fun, and also, for full control over what the extractor does, to come up with a result i like, i might have to use 4 different self extracting archive utilities, or, i could make my own.
pasztorpisti 26-Jul-13 11:32am    
Even in that case its fairly straightforward how to do that. You are just creating the exe and appending a zip or whatever archive to the end of your exe. In the exe you will perform only simple filesystem operations and you should use a compression library (I would make an interface for the compression libs to make it easy to replace the compressor lib to anything if needed). I think the most complicated part for a beginner is running decompression on a worker thread to keep the gui (progressbar/buttons) responsive while decompressing and maybe finding the start offset of the appended compressed data at the end of the exe. Start writing your program and ask questions about smaller problems that arise during development.
Sicppy 27-Jul-13 17:35pm    
Why would i append .zip? That renders the file useless as an exe.
Here is a well admired open source solution of the zip packing http://www.7-zip.org/[^]
 
Share this answer
 
Comments
Sicppy 26-Jul-13 8:23am    
Thanks, but as i mentioned in the question, I would like to make it with native c++, so i can distribute 1 .exe file with no dependencies
Firstly you can use the following function :
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx[^]
to retrieves the path of the directory designated for temporary files (%WINDIR%\temp)

Like this:
C++
TCHAR buf [MAX_PATH];

if (GetTempPath (MAX_PATH, buf) != 0)
{
  //Here you can to do extracting yours archive, run script

}


Use one of the following examples:
http://www.example-code.com/vcpp/vcUnzip.asp[^]
Zip Utils - clean, elegant, simple, C++/Win32[^]]
Zip and Unzip in the MFC way[^]
Easy Way to Read/Write Zip-Compatible Files Under MFC[^]

Good luck
 
Share this answer
 
Comments
Sicppy 27-Jul-13 15:59pm    
Thank you for your detailed solution, i posted this same question on stack overflow and all i got were a bunch of people saying it would take to long, or its impossible, if your interested in helping me work on this project, just email me at officialtoxicdub@gmail.com essentially what im doing, is creating a simple, flexible installer creator, for programmers that aren't quite making enough income to afford one of the more popular installer creators, or don't want to learn NSIS, this project will be distributed completely free.
Volynsky Alex 28-Jul-13 14:41pm    
Glad I could help.
I'm really swamped with work right now, but I'll be glad to help you in the future...You're welcome. :)

Regards,
Alex.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900