How can I pass arguments to a batch file?
arguments, batch-file
Solution
Here's how I did it:
@fake-command /u %1 /p %2
Here's what the command looks like:
test.cmd admin P@55w0rd > test-log.txt
The `%1` applies to the first parameter the `%2` (and here's the tricky part) applies to the second. You can have up to 9 parameters passed in this way.
Problem
I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file. Here's what the command line looks like: ``` test.cmd admin P@55w0rd > test-log.txt ```
Related problems
- Using parameters in batch files at Windows command line
- Single script to run in both Windows batch and Linux Bash?
- What is the at sign (@) in a batch file and what does it do?
- Is there a way to indicate the last n parameters in a batch file?
- how to get batch file parameters from Nth position on?
- How to receive even the strangest command line parameters?