Batch Script pass parameters

I need to pass two parameters to a batch script at execution. Could someone please advise of the syntax. Fields I need to pass

Folder String : This will be a folder name e.g.  c:\MyFolder

File String: This will be a filename e.g. Myfile.csv
Diane LonerganIT Operations MgrAsked:
Who is Participating?
 
Bill PrewCommented:
Batch file "myscript.bat":

@echo off
echo Parm1:%1
echo Parm2:%2

Open in new window


Command line invocation passing parms:

myscript c:\MyFolder Myfile.csv

Open in new window


»bp
0
 
Bill PrewCommented:
And if you use quotes on the command line (required if they contain spaces), like:

myscript "c:\MyFolder" "Myfile.csv"

Open in new window

Then %1 and %2 will also have the quotes around the value.  You can remove those when referencing by using %~1 and %~2.


»bp
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.