How do I put arguments in my batch file?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

How do I put arguments in my batch file?

#1 Post by phillid » 03 Apr 2010 20:38

I know this sounds a dumb and simple question, but how do I put arguments in my batch file? For example, I want to be able to run some of my own batch files from the command line like:

example.bat /A /2 /F /T

--OR--

example.bat -W +E -1 -G +5

Can I please get some help on how to do this? Am I able to have -1 and +1 being opposite args (like the ATTRIB command)???

Thanks for any reply... :?

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: How do I put arguments in my batch file?

#2 Post by !k » 03 Apr 2010 23:12

Use the variables from %1 to %9, and SHIFT command if more than 9 arguments

---saster---
Posts: 5
Joined: 07 Apr 2010 06:49

Re: How do I put arguments in my batch file?

#3 Post by ---saster--- » 07 Apr 2010 07:47

@echo off
:lp
if "%~1"=="" goto:eof
for %%_ in (-s,-w,-t,-n,/b,/a) do (
if ["%~1"]==["%%~_"] echo You write %%~_)
shift
goto lp

with this you can do it

Post Reply