Computer Management bat files - Part 3: Menu script
In today's article we are going over how to create a menu for our users and groups management script. If you haven't read it you may want to start at article one Computer management bat files - Part 1: Users and Computer management bat files - Part 2: Groups
Menu Script
This is really simple we are just going to follow the same techniques we used in our other scripts but this time lay our a menu using echo, set, if, and a variable to let the user select a number on the menu.@echo off :UserMenu CLS echo ============Users Menu============ echo. echo ============Users============ Net User echo. echo ============Groups============ Net Localgroup echo. echo Choose An option: echo 1. View a User echo 2. Add a User echo 3. Disable a User echo 4. Enable a User echo 5. Change User Password echo 6. Add User to group echo 7. List Users of a group echo 8. Remove User from group echo Q. Back To Main Menu SET INPUT= SET /P INPUT=Please select a number: IF /I '%INPUT%'=='8' goto REMGroup IF /I '%INPUT%'=='7' goto ListGroupUsers IF /I '%INPUT%'=='6' goto AddGroup IF /I '%INPUT%'=='5' goto Password IF /I '%INPUT%'=='4' goto EnableUser IF /I '%INPUT%'=='3' goto DisableUser IF /I '%INPUT%'=='2' goto AddUser IF /I '%INPUT%'=='1' goto ViewUser IF /I '%INPUT%'=='Q' goto MainMenu CLS echo ============INVALID INPUT============ echo ------------------------------------- echo Please select a number from the User echo Menu [1-8] or select 'Q' to quit. echo ------------------------------------- echo ======PRESS ANY KEY TO CONTINUE====== PAUSE > NUL GOTO UserMenu
Here is how the menu looks when you run it.
Since we don't have any of the code to actually jump to the menu is currently just to look at. Now that we have the menu all setup and ready to go next time we will add the menu and all our scripts together.
Since we don't have any of the code to actually jump to the menu is currently just to look at. Now that we have the menu all setup and ready to go next time we will add the menu and all our scripts together.
Comments
Post a Comment