Search code examples
javacompressionextractexecutionwinrar

How does "Winrar" execution task work?


I have a question which is very important to me. I've searched with Google, but found nothing. The question is:

How can WinRAR execute a game or software, etc. by just clicking on the .exe file without extracting the files of the software or game?

Can someone please explain that for me with code for Java?

I want to make a software similar to WinRAR, but I don't understand that point.


Solution

  • Open in WinRAR the menu Options, click on menu item Settings, select tab Viewer and look on option Unpack everything for.

    Press now button Help and read explanation for option Unpack everything for.

    As you can read, WinRAR extracts all files of the archive on double clicking on a *.exe inside the archive to a temporary folder created in folder for temporary files - environment variable TEMP - respectively the folder defined on tab Paths for Folder for temporary files in the Settings dialog.

    Then WinRAR starts the EXE in the temporary folder and monitors the process. After the started application has terminated, WinRAR deletes the temporary folder with all files and subfolders.

    Of course in case of exiting WinRAR before exiting the started application, WinRAR let all extracted files in temporary folder forever and the user has to delete them for example with the Windows Disk Cleanup tool.

    Same steps are done for example also by Microsoft Outlook for a single file if a double click is made on a file attached to an email. The file is extracted temporarily from the email to a folder for temporary extracted email attachments and deleted automatically by Outlook if the application started to open and display the file has exited. But again the temporary extracted file attachment is kept in the folder and must be deleted later by the user if Outlook itself is exited before the application used to view the temporary extracted file has exited.

    In other words, also WinRAR cannot run an application directly from within an archive without extracting first all files of the archive to somewhere on hard disk.