Computing.Net > Forums > Disk Operating System > Use switches on batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Use switches on batch file

Reply to Message Icon

Name: nmv (by AP81)
Date: February 22, 2006 at 16:57:53 Pacific
OS: Dos 7
CPU/Ram: 3200XP/1G
Comment:

I would like to assign switches to a batch file. I am asking here because I haven't been able to find much on the net, and the information that I have found is not detailed enough.

For example, I have a file called backup.bat (or backup.com after converting it to a .com file)
I want to be able to issue the commands:

backup /check
backup /verbose

What do I need to do in my batch file (or converted com file) to enable these switches?

Any examples / help is greatly appreciated.

Thanks,

Adam



Sponsored Link
Ads by Google

Response Number 1
Name: jboy
Date: February 22, 2006 at 18:11:43 Pacific
Reply:

Batch files don't generally work with switches - unless you use replaceable parameters (%1 %2 etc), or else use the actual command & parameter, within the batch

Science is built up with facts, as a house is with stones. But a collection of facts is not more a science than a heap of stones is a home


0

Response Number 2
Name: KasMage15
Date: February 24, 2006 at 09:51:11 Pacific
Reply:

Start the program out something like this:

@ECHO OFF
IF "%1" == "/?" GOTO HELP
IF "%1" == "/C" GOTO COPY

Then keep it going. %2 is the second parameter, %3 is the third parameter, etc. But this is usually only good if only one parameter is loaded at a time. If you have a program that loads multiple parameters (ex. SCANDISK /AUTOFIX /SURFACE) it will be hard to get it to work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Use switches on batch file

BOOK ON BATCH FILE MAKING www.computing.net/answers/dos/book-on-batch-file-making/2418.html

Compilina VB programs using a DOS batch file www.computing.net/answers/dos/compilina-vb-programs-using-a-dos-batch-file/5233.html

batch file www.computing.net/answers/dos/batch-file/9930.html