After packaging an EXE file with RAR, how to let others automatically delete the EXE file after installation?
Turn to an article of DIY tribe (). If you pack, go directly to step 5. The first step is to reduce the weight of jre, delete the unused classes in jre\lib\rt.jar, and delete the unused character set code MyWork in charsets.jar The open source project () has a slim JRE6.0, which is very small, only a few meters. If necessary, you can gain weight appropriately on this basis, such as suggesting that you can't find a class. Just find the package to which this class belongs in the complete jre rt.jar package and add it to the compact jre. The second step is to use pack200 for compression, and the compression effect is amazing. Please refer to the official manual for specific usage. The following is the simplest compression and decompression command (compression is not recommended if you want to install the package, because it is not convenient to decompress, and you need to write another program to decompress). Compression command d: \ xxxxx \ pack200 rt.jar.pack.gz rt.jar decompression command unpack200-rjre \ lib \ rt.jar.packjre \ lib \ rt.jar Step 3, make your own program into a jar package, pay attention to specifying the main class, and put it together with the dependent jar package under jre\lib\ext. The advantages of putting the class path directly under ext by writing batch processing will be reflected in the following. Step 4, write the function to start batch% 1 in the upper directory of jre folder. @SET PATH=。 /JRE/bin; % 1; % PATH %@ start javaw com. Main (change it into your own program entry according to the actual situation) Rename the local jre or jdk folder, click java under cmd to confirm that the local jre has failed, click batch processing to test whether the program starts normally, and continue reading. If the program cannot start, rewrite @start javaw com. Main of java com. Main and restart debugging to see if any classes are missing. Step 5: Compile the batch into an exe program and use the quick batch file compilation tool (). The program is very simple to use, so I won't introduce it here. If E is not good, you can download Chinese in Chinese New Century. Note that if you want to make an installation package, you must use ghost mode instead of console mode. Step 6, make an installation package with InnoSetup tool (downloaded by Baidu everywhere). This tool has a guide, so this part will not be introduced. After the wizard is completed, you will be prompted to generate a script, save this script, generate an exe installation package, and run the installation package. If the generated file program structure is the same as that in step 4 and can be run, the installation package is completed. (When selecting the program file in this step, batch exe and jre are added together. Note that jre must not be compressed by pack2000, otherwise you need to write a decompressor in the installation script. Step 7, use windows to automatically start the program, modify the installation script and add the following code [registry] Root:HKLM;; Sub-item: "Software \ Microsoft \ Windows \ Current Version \ Run"; ValueType: string; ValueName: "program name"; Valuedata: ""\ Main program. This is used in% 1 Students familiar with batch processing know that the system startup does not represent the folder where the program is located, so the folder parameter of JRE is passed here, @SET PATH=. /JRE/bin; % 1; % PATH %Jre has been added to the path. Step 8, log in again to see if the program starts automatically. (It can be tested on a machine without jre installed. The size of my installation package is about 10M, which depends on many third-party jar packages, otherwise it can be smaller. Finally, I can add a shell or use rar compression.