views:

2546

answers:

2

I like to know if there is a way to read the user input inside a batch file, because i have a file named: "fif.bat" that recives two parameters (just call them paramA and paramB) so i execute the file like this:

fif paramA paramB

I have to change paramA every month, but i call this file lot of times so i like to open a console and have printed this:

fif paramA

So i only have to write paramB and change paramA when i want it.

PD: paramA is very large so it's very helpful if i can have it there instead of writing every time. And i don't want to make another batch file to call fif whit paramA.

A: 

You can prompt for user input in a batch file using SET /P for example:

SET /P paramB="Prompt String: "
Dave Webb
+3  A: 

I think this might be what you're looking for:

@ECHO OFF
SET /p paramA=Parameter A:
ECHO you typed %paramA%
PAUSE

Line one stops commands in batch file from being echoed to the console Line two prompts the user with "Parameter A:" and waits for user to enter a value and press enter. The value goes into a variable called paramA. Line three echoes the value of the variable paramA to the console Line four waits for the user to hit any key.

Note that the SET /p command does not work on every version of windows, I beleive it was introduced in 2000, but I could be wrong on the version.

Jeremy
It's not exactly what i looking for, but it helps me very much. Thanks.
unkiwii