Script: DOS Menu Batch File

Posted by : on

Category : dos   script


Earlier today, I created a batch file to handle a small delima I was having. I have been assigned a project to build an Application Installation Image (ISO). This ISO will need testing in three different environments (DEV = A, QB = B, PROD = C). The ISO is exactly the same except for the config files. The config files are geared for each individual environment (A, B, & C). In the past, the ISO had to be rebuilt each time for each different environment because the config files had to be included within the Application build. The rebuild process took several hours. Instead of rebuilding the ISO for each individual environment to test in, my co-workers and I decided to build one Golden Image, move all of the config files into a central location, and copy only the needed config files into the application folder (overwriting the ones that were installed from the Golden Image). Once the ISO has been given the green light to be deployed to the company, we would then install the final config files within the final Application ISO build.

For example: Golden Application Image (base_env) is installed on WIN XP. Testing with Development is needed (Env A). Copy “Env A” config files to the Application folder on the XP machine. Then when testing is needed in other groups (ie., QA - Env B, and Prod - Env C), all that would be needed is to copy “Env B” and “Env C” config files when needed.

I’ve been copying the files over both via command-line and using ‘Explorer’. I wanted to make this simpler, so I created a DOS based menu within a batch file. Since I haven’t used batch scripting in a while, I wanted to share my code. I’ve modified this code so that my company’s info is not shared publicly. I made reference to this website during the writing of the code.

@echo off
REM +++++++++++++++++++++++++++++++++++++
REM +++ DOS Batch Menu v 0.2 +++
REM +++ written by J. Sam Aaron +++
REM +++ 09.21.2010 +++
REM +++++++++++++++++++++++++++++++++++++

REM - MENU LAYOUT
goto menu
:menu
echo *****************************
echo * *
echo * What file(s) do you need? *
echo * *
echo *****************************
echo * *
echo * Choice *
echo * *
echo * 1. +File A *
echo * 2. +File B *
echo * 3. +File C *
echo * 4. +EXIT *
echo * *
echo *****************************

REM - MENU VARIABLES
:choice
set /P C=[1,2,3,4]?
if "%C%"=="4" goto quit
if "%C%"=="3" goto filec
if "%C%"=="2" goto fileb
if "%C%"=="1" goto filea
goto choice

REM - MENU CHOICES
:intg
xcopy "CFG\*.*" "C:\Program Files\Application\CFG\"
cls
goto menu

:syst
xcopy "CFG\*.*" "C:\Program Files\Application\CFG\"
cls
goto menu

:prod
xcopy "CFG\*.*" "C:\Program Files\Application\CFG\"
cls
goto menu

:quit
exit

:end


About Sam Aaron
Sam Aaron

Father, Husband, Geek. Workaholic.

Email : mail@micronauts.us

Website : http://micronauts.us

About Sam Aaron

Father. Husband. Geek. Workaholic. US Marine Corps Veteran.

Sam Aaron is a Senior Consultant in the Professional Services Organization for Entelligence, bringing over a decade of expertise in enterprise cloud automation and infrastructure. Sam has spent almost eleven years at VMware leading cloud automation initiatives using VCF Automation (formerly Aria Automation & vRA) and designing scalable, multi-tenant environments with VMware Cloud Director (vCD).

Sam holds multiple certifications including VCF-Architect 2024, VCIX-CMA, and dual VCPs (DCV & CMA), and is a recognized contributor to VMware’s certification exams. As a VMware Hands-On Lab (HOL) Captain and content author from 2015-2025, Sam played a key role in educating and mentoring the global VMware community. He helped to create and develop the automation challenge and troubleshooting labs for VMworld and global virtual forums.

When Sam is not working, he has several hobbies, among these are 3D printing Star Wars robots and turning them into animatronics.

Launched in April 2010, micronauts is Sam's online presence. Here, he has been blogging and sharing knowledge with the virtualization community. This blog acts as a central repository to retain the resolutions and other trivial knowledge that Sam has discovered.

** No information provided here was reviewed or endorsed by VMware by Broadcom, Microsoft, or anyone else for that matter. All information here are opinions based on Sam's personal experience. Use this knowledge at your own risk. **

Star
Useful Links