问题
Is there a way to extract a self extracting exe from commandline in windows?
I have a self extracting exe which is of type RAR. I want to extract the contents of this RAR only with the help of windows and not using any other tools (like 7zip, Unrar etc) which helps to extract. Also, I want to do it from the command line only.
Are there any utilities in windows which I can use to extract the self extracting exe file from commandline?
回答1:
You might be able to get the self-extacting RAR archive to do what you want with one or more of the following RAR SFX (self-extracting archive) options:
GUI self-extracting modules support following command line switches:
-d<path> set the destination path -p<pwd> specify a password -s silent mode, hide all -s1 same as -s -s2 silent mode, hide start dialog -sp<par> specify parameters for setup program
I'm not sure if any of these options will suppress running a setup program that the SFX is configured to run.
回答2:
Download UnRar for windows (freeware) from this link. It in itself is a self extracting archive, which when installed will give you the actual unrar.exe. You can then use unrar.exe to extract files from the command line.
回答3:
Use unzip utility from http://www.info-zip.org/. It is an open source and binaries are available for all os flavors.
unzip command: unzip.exe sample.zip -d extract_folder
Download latest windows executable at ftp://ftp.info-zip.org/pub/infozip/win32/. After downloading the binary like 'unz552xn-x64.exe', run it in command line, it will give a set of files including unzip.exe. since unzip.exe does not have any dependency other files can be deleted.
回答4:
For others that are looking for the answer to this.
Download the trial version or purchase WinRAR. Right click the files you want to package and select add to archive.
Check "create sfx archive" on the General tab, this will give you the file.exe
Select the "sfx options" on the Advanced tab, under the Modes tab select "hide all". If you don't want the extracted files to show or stay after your program/script has run then "Unpack to temporary folder" under this same tab.
Under the Setup tab in the "run after extraction" put the program or script you would like to run.
Once file(s) have been packaged you will have a file called file.exe. (Note:File will be what you named the sfx archive). From command line type file.exe and it will extract to the temp location (if you selected that) and run the program/script that you specified. Once the program/script closes the folder in the temp location will be removed.
Notes:
If running from a WinPe CD or otherwise similar bootable media do not use "Unpack to Temporary Folder".
WinRAR only has to be on the computer making the sfx archive. Once the sfx archive is made you won't need it to extract the files.
来源:https://stackoverflow.com/questions/9194589/how-to-extract-a-self-extracting-exe-from-commandline