Batch file help

G

Guest

I apologize if this is the wrong forum, but there are so many groups and I
didn't know what one to write this in. I've been working on a backup batch
file to backup data on some machines and now I would like to add some command
line switches for my batch file.

Couple of questions:

1)Is there anything you can do about the order of how they add the switches?

c:> example.bat -nodocs -nofavs

c:> example.bat -nofavs -nodocs

--------------------------------------------------------------------------------
example.bat
--------------------------------------------------------------------------------

if %1== nodocs set docs=0
if %2== nofavs set favs=0
..
..
..

--------------------------------------------------------------------------------

This is just a crude exanple. but you see my point. Obviously this would
work for the first example, but would fail on the second because the switches
are in the wrong order. Is there a way you can get around this? I would hate
to tell the other guys that you HAVE to enter the switches in this exact
order.


2) How do you avoid if the user doesn't supply any switches?

Using the example above:

-------------------------------------------------------------------------------

if %1== nodocs set docs=0
if %2== nofavs set favs=0
..
..

--------------------------------------------------------------------------------

How do I handle if the user doesn't supply any switches at all?

c:> example.bat

This is going to give me an error because the if command is looking for a
switch. I tried using "if %1== goto noswitch" and "if %1=="" goto noswitch"
but both came back with the unexpected return error.

Like I said I apologize if this is the wrong forum. Point me in the write
direction if it is. Thanks.
 
M

Mark F.

notta said:
I apologize if this is the wrong forum, but there are so many groups and I
didn't know what one to write this in. I've been working on a backup batch
file to backup data on some machines and now I would like to add some command
line switches for my batch file.

Try at
alt.msdos.batch
and
alt.msdos.batch.nt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top