- Strange failure in batch file.
- Posted by Poster Matt on July 4th, 2008
Hi,
Using WinXP SP2 (up to date).
I've been writing the occasional batch file for Microsoft OSes since
about 1990 and never had a problem like this.
I have a batch file that archives various directories for backup
purposes. Until recently I've used a command line PKZip program
(PKZip25), but now I want the added flexibility of RAR archives so am
switching to that.
My 'DailyBackup.bat' file has been converted to use the command line
utility that comes with WinRAR, called appropriately 'rar.exe'.
The following single line from my bat file (below split onto 2 lines to
avoid word wrap problems) is typical of the command lines in the bat file.
"C:\Program Files\WinRAR\rar" a -rr5% -m5 -o+ -ep2 -r
"D:\BackUp\DailyRAR\notes.rar" "D:\Text\Notes\*.*"
Now that line works perfectly and as expected when run directly from the
Win 'Command Prompt'. But as soon as I put it in a .bat file all I get
is the 'rar.exe' utility's standard usage help text output (the one that
shows how to format a line and the commands and switches list) as if I'd
typed 'rar -?'.
I've tried tests with various single line commands from the prompt and
then putting the exact same line in a .bat file and get the same result
each time; fine on the command line, failure in a .bat file.
I'm perplexed as to why this is happening in the batch files having
never run into such a situation before.
Any advise as to why this is happening and resolving it would be
appreciated.
Many thanks.
PS. Anyone know of an alternative free command line RAR achiver utility
for Win XP.
- Posted by billious on July 4th, 2008
"Poster Matt" <postermatt@no_spam_for_me.org> wrote in message
news:HMrbk.20727$E41.1328@text.news.virginmedia.co m...
I'd suggest you double-up the "%" after the "5"
If you put
ECHO ON
before your line and
@echo off
after, you will see the ACTUAL line that is being executed echoed to the
screen.
Oh, BTW XP SP3 is the latest, IIRC.
- Posted by Poster Matt on July 4th, 2008
Hi,
billious wrote:
Thanks so much, adding an extra '%' fixed it. I didn't realize that was
needed in .bat files.
Yes, the single '%' corrupted the line.
I should have tried that
before posting.
I'll wait till they've fixed all the bugs and the inevitable security
problems with a major SP release.
Thanks for your help.
Regards, etc..
- Posted by Timo Salmi on July 4th, 2008
Poster Matt <postermatt@no_spam_for_me.org> wrote:
Standard batch lore. The % needs to be escaped. In the case of % the
escape character is another %. Depending on the circumstances and the
character involved, the other escape characters in XP scripts are
^ and \
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm
- Posted by ShadowTek on July 4th, 2008
I prefer 7zip. It'll handle RAR files, and it's open source.
- Posted by ShadowTek on July 4th, 2008
ShadowTek <psistormyamato@_NO_SPAM_cs.com> wrote in
news:Xns9AD1904DDE331psistormyamatocscom@85.214.90 .236:
Actually, 7zip only decompresses RAR files. But the 7z compression
algorithm is also very good.
- Posted by Poster Matt on July 5th, 2008
ShadowTek wrote:
RAR has a great feature not usually found in other compression archivers
and that's a recovery record, this can be v. useful.
- Posted by ShadowTek on July 6th, 2008
The most use I get out of RAR is the multitude of dynamic integrated
context menu items with the GUI WinRAR. It has the best of any other
archiver that I have ever used.