Discussion Locked

New to scripting

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Can someone provide me an sight on creating a batch file which would accept 2 inputs from the user. put them to work in an NT command inside the batch file. and produce result.

6 replies

by joseph moore

You could use the variables %1 and %2 for command-line inputs. For example, setup a BAT file (TEST.BAT)with the following:

echo file name 1: %1
echo file name 2: %2
pause
dir %1
pause
echo hi again %2

At the command line type TEST.BAT FILE1.TXT FILE2.TXT
And here is the output:

file name 1: FILE1.TXT
file name 2: FILE2.TXT
Press any key to continue . . .
Volume in drive C has no label.
Volume Serial Number is 1489-87EB

Directory of C:\TEMP

04/05/00 05:01a 110,000 FILE1.TXT
1 File(s) 110,000 bytes
2,753,249,280 bytes free
Press any key to continue . . .
hi again basic.pdf

So, I did a directory listing with one of the file names from the %1 variable, and just displayed the 2nd file name from the other variable. I used the PAUSE just to break things up, to be easier to read.
Whatever goes in those variables is free game, just like any data in a variable. Do with it what you wish.

Hope this helps.

by joseph moore

Forgot to change something. The last output line should read "hi again FILE2.TXT". I guess you now know one of the real files I did my test with!!!

This discussion is closed to new replies.