Friday 13 April 2012

Batch programming: defaulting user input

This is a really simple script which sets a variable to a default value if the user doesn't provide input when asked.

set /P val=Please enter value: || set val=default


If the user enters a value, the %val% variable is set to the given value. Otherwise (if the user simply pressed Enter) 'default' is used instead.

Neat :).

Thoughts?

2 comments:

loopkin said...

Exactly what I needed. Thanks!

Elinor said...

Glad to have been of help.

Online Marketing
Add blog to our blog directory blog search directory Blog Directory Blogarama - The Blog Directory