Batch scripting is a text file containing a series of commands intended to be executed by the command interpreter. Much like a unix / linux shell script, the purpose of a batch script is to sequentially process a series of commands.

Tags | |

How to get user input in a batch (Bat) script

Batch Tutorial: getting a users input in a batch script



Example shown: Getting a input variable from a user



Batch user input text example:



@echo off

Echo =============================================

echo User input example

Echo =============================================

set /p user_name=What is your user name:

Echo %user_name% was what you typed

pause



You may be saying, big deal, you can set a name. Well this can be a critical step in the creation of tools for any administrators automation kit.



Another example of this assumes that you are in an active directory enviroment. This tool will allow you to enter a users name and check that users account information without having to load the AD toolkit.




@echo off

Echo #####################

Echo This tool will help you get the users info

Echo #####################

set /p user=What is the User name to query:

net user %user% /domain

pause

exit





Comments

Feel free to leave a comment or question

Name: (Optional but appreciated):

Comment:

Use [code] [/code] for code block style



Security Code: