• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

How to write a batch file in Windows?

I would like to write a batch file in Windows to run the following commands
xyz.bat -u A \\some\path\in\here\somefileName.bat -v
cd \\to\a\directory\given\as\an\input\to\the\batch\file

xyz.bat -u A \\run\a\perl\file\inhere\fileName -option A -option B

Open in new window

As I mentioned in the sudo code above, the directory that I want to cd to will be given as an input to the batch file.

Also, the following part will also be an input the to batch file:


Open in new window

The options will not be an input. They will be hard coded in the batch file.

so basically the sudo code can also be summarized like this:

xyz.bat -u A \\some\path\in\here\somefileName.bat -v
cd $directory

xyz.bat -u A $file -option A -option B

Open in new window

Can you please tell me how I can write this code?
1 Solution
instead of $directory and $file, the parameters come in as %1 and %2.

just use %1 and %2, and the parameters will go in as typed

xyz.bat -u A \\some\path\in\here\somefileName.bat -v
cd %1

xyz.bat -u A %2 -option A -option B
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.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now