General discussion

Locked

New to scripting

By nt ·
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.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

New to scripting

by yorkster In reply to New to scripting

try using the "choice" command inside your batch file

Collapse -

New to scripting

by nt In reply to New to scripting

Poster rated this answer

Collapse -

New to scripting

by Joseph Moore In reply to New to scripting

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.

Collapse -

New to scripting

by Joseph Moore In reply to New to scripting

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!!!

Collapse -

New to scripting

by nt In reply to New to scripting

Thanks Joseph!!

Collapse -

New to scripting

by nt In reply to New to scripting

This question was closed by the author

Back to Windows Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums