![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 06:08 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Fixed] Question about using a batch file to create self-extracting archives |
| Printable Version 1,286 / 10 |
| Floor1 luoluo4413 | Posted 2010-09-26 13:18 |
| 新手上路 Posts 6 Credits 6 | |
|
Already solved, many thanks to bozhou!!
Hello everyone, I want to batch-generate self-extracting files. How should the batch file be written? I want to create the above a directory as the self-extracting file a.exe, the b directory as the self-extracting file b.exe, and the c directory as the self-extracting file c.exe — these three self-extracting files (the generated EXE filename should be based on the folder name). Also, after a.exe is extracted it should create a shortcut pointing to a/a1.exe, after b.exe is extracted it should create a shortcut pointing to b/b1.exe, and after c.exe is extracted it should create a shortcut pointing to c/c1.exe. How can this be done? Right now, with the script I wrote, I can only manually modify each directory name and executable filename to create the self-extracting file! How can I modify my script to make it work in batch? Here is my current script aa.bat: "C:\Program Files\WinRAR\rar.exe" a -sfx -iiconcos.ico a.exe -ap d:\game\a -zren.txt pause Below is the content of ren.txt: Shortcut=s, "a/a1.exe", "Test", "Test", "Test1" Shortcut=p, "a/a1.exe", "Test", "Test", "Test1" Also, is it possible to integrate the comment file zren.txt into the aa.bat batch script above? Hope all the experts can help! [ Last edited by luoluo4413 on 2010-10-9 at 10:13 ] |
|
| Floor2 yishanju | Posted 2010-09-26 13:42 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
C:\Documents and Settings\ZW>rar /?
RAR 3.61 Copyright (C) 1993-2006 Alexander Roshal 14 Sep 2006 Shareware version Enter RAR -? for help Usage: rar <command> -<switch 1> -<switch N> <archive> <files...> <@listfiles...> <extract path\> <Commands> a Add files to archive c Add archive comment cf Add file comments ch Change archive parameters cw Write archive comment to file d Delete files from archive e Extract files to current directory f Freshen files in archive i[param]=<str> Find string in archives k Lock archive l[t,b] List archive contents[technical, bare] m[f] Move to archive[files only] p Print file to stdout r Repair archive rc Reconstruct missing volumes rn Rename archived files rr[N] Add data recovery record rv[N] Create recovery volumes s[name|-] Convert archive to or from SFX t Test archive files u Update files in archive v[t,b] Verbosely list archive contents[technical, bare] x Extract files with full path <Switches> - Stop switches scanning ac Clear archive attribute after compression or extraction ad Append archive name to destination path ag[format] Generate archive name using the current date ao Add files with archive attribute set ap<format> Set path inside archive as Synchronize archive contents av Add authenticity verification(requires registered version) av- Disable authenticity verification c- Disable comments show cfg- Disable read config cl Convert names to lower case cu Convert names to upper case df Delete files after archiving dh Open shared files ds Disable sort for solid archives e[+]<attr> Set file exclude and include attributes ed Do not add empty directories en Do not add "end of archive" block ep Exclude paths from names ep1 Exclude base directory from names ep2 Expand to full paths ep3 Expand paths to full including the drive letter f Freshen files fcu[file] Read archive comment from Unicode file hp[password] Encrypt both file data and headers id[c,d,p,q] Disable messages ieml[attr] Send archive by E-mail ierr Send all messages to stderr ilog[name] Log errors to file(requires registered version) inul Disable all messages ioff Turn PC power off after completing an operation isnd Enable sound k Lock archive kb Keep broken extracted files m<0..5> Set compression level(0-store...3-default...5-maximum) mc<params> Set advanced compression parameters md<size> Dictionary size in KB(64,128,256,512,1024,2048,4096 or A-G) ms[ext;ext] Specify file types to store mt<threads> Set the number of threads n<file> Additionally filter included files n@ Read additional filter masks from stdin n@<list> Read additional filter masks from list file o+ Overwrite existing files o- Do not overwrite existing files oc Set NTFS compressed attribute or Rename files automatically os Save NTFS streams ow Save or restore file owner and group p[password] Set password p- Do not query password r Recurse subdirectories r0 Recurse subdirectories for wildcard names only ri<P>[:<S>] Set priority(0-default,1-minimum..15-maximum) and sleep time in ms rr[N] Add data recovery record rv[N] Create recovery volumes s[<N>,v[-],e] Create solid archive s- Disable solid archiving sfx[name] Create SFX archive st[name] Read data from stdin sl<size> Process files smaller than the specified size sm<size> Process files larger than the specified size t Test files after archiving ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format tk Keep original archive time tl Set archive time to latest file time tn<time> Process files newer than <time> to<time> Process files older than <time> ts<m,c,a>[N] Save or restore file time(modification, creation, access) u Update files v Auto-detect volume size or list all volumes v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1] vd Erase disk contents before creating volume ver[n] File version control vn Use old style volume naming scheme vp Pause before each volume w<path> Assign work directory x<file> Exclude specified file x@ Read file names to exclude from stdin x@<list> Exclude files listed in specified list file y Assume Yes on all queries z[file] Read archive comment from file |
|
| Floor3 luoluo4413 | Posted 2010-09-26 14:21 |
| 新手上路 Posts 6 Credits 6 | |
|
I know all the RAR command switches. I'm just not very familiar with DOS batch scripts, so I don't know how to write it.
|
|
| Floor4 luoluo4413 | Posted 2010-09-30 22:25 |
| 新手上路 Posts 6 Credits 6 | |
|
Is anyone still here? Why hasn't anyone given a reply?
|
|
| Floor5 bozhou | Posted 2010-10-03 21:56 |
| 初级用户 Posts 19 Credits 38 | |
|
Use it together with the FOR command.
|
|
| Floor6 bozhou | Posted 2010-10-03 23:18 |
| 初级用户 Posts 19 Credits 38 | |
|
Write the code as follows; it has been tested and works.
|
|
| Floor7 luoluo4413 | Posted 2010-10-07 23:21 |
| 新手上路 Posts 6 Credits 6 | |
|
Replying to the brother in post #6: the exe filename under the directory is not fixed. It is the file with the .exe extension found by searching inside a certain directory.
It may be that the executable under folder a is not a1.exe, it could be xxx.exe. How can I get it? |
|
| Floor8 bozhou | Posted 2010-10-08 19:35 |
| 初级用户 Posts 19 Credits 38 | |
|
Well, you didn't explain it that clearly at first...
Also, is there only one exe file under folder a? [ Last edited by bozhou on 2010-10-8 at 19:39 ] |
|
| Floor9 luoluo4413 | Posted 2010-10-08 22:31 |
| 新手上路 Posts 6 Credits 6 | |
|
Oh, sorry, my mistake! There is only one exe file under folder a. Cases with multiple exe files are not being considered.
|
|
| Floor10 bozhou | Posted 2010-10-09 00:25 |
| 初级用户 Posts 19 Credits 38 | |
|
As follows:
|
|
| Floor11 luoluo4413 | Posted 2010-10-09 10:12 |
| 新手上路 Posts 6 Credits 6 | |
|
Thanks bozhou, it's solved!
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |