Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange failure in batch file.

6 views
Skip to first unread message

Poster Matt

unread,
Jul 4, 2008, 11:58:31 AM7/4/08
to
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.

billious

unread,
Jul 4, 2008, 12:21:00 PM7/4/08
to

"Poster Matt" <postermatt@no_spam_for_me.org> wrote in message
news:HMrbk.20727$E41....@text.news.virginmedia.com...

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.

Poster Matt

unread,
Jul 4, 2008, 12:34:05 PM7/4/08
to
Hi,

billious wrote:
> I'd suggest you double-up the "%" after the "5"

Thanks so much, adding an extra '%' fixed it. I didn't realize that was
needed in .bat files.

> 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.

Yes, the single '%' corrupted the line. :( I should have tried that
before posting.


> Oh, BTW XP SP3 is the latest, IIRC.

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..

Timo Salmi

unread,
Jul 4, 2008, 1:16:14 PM7/4/08
to
Poster Matt <postermatt@no_spam_for_me.org> wrote:
> billious wrote:
>> I'd suggest you double-up the "%" after the "5"
>
> Thanks so much, adding an extra '%' fixed it. I didn't realize that was
> needed in .bat files.

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:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm

ShadowTek

unread,
Jul 4, 2008, 2:11:08 PM7/4/08
to
> PS. Anyone know of an alternative free command line RAR achiver
> utility for Win XP.

I prefer 7zip. It'll handle RAR files, and it's open source.

ShadowTek

unread,
Jul 4, 2008, 3:14:51 PM7/4/08
to
ShadowTek <psistormyamato@_NO_SPAM_cs.com> wrote in
news:Xns9AD1904DDE331p...@85.214.90.236:

>> PS. Anyone know of an alternative free command line RAR achiver
>> utility for Win XP.
>
> I prefer 7zip. It'll handle RAR files, and it's open source.

Actually, 7zip only decompresses RAR files. But the 7z compression
algorithm is also very good.

Poster Matt

unread,
Jul 5, 2008, 8:48:14 AM7/5/08
to

RAR has a great feature not usually found in other compression archivers
and that's a recovery record, this can be v. useful.

ShadowTek

unread,
Jul 5, 2008, 11:19:38 PM7/5/08
to
> RAR has a great feature not usually found in other compression archivers
> and that's a recovery record, this can be v. useful.

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.

Poster Matt

unread,
Jul 9, 2008, 8:58:23 AM7/9/08
to

Yes the context menu is v. useful. Highlighting files and/or folders and
then taking you straight to the 'Add to archive' dialog is great, as is
the 'Extract to folder' where the folder name is the name of the archive
file with it's extension removed - so useful.

It also extracts everything I've ever thrown at it, including a few
things I didn't expect it to handle EG. UUE.

Highly recommended software, a killer app. IMO.

0 new messages