Batch File To Prompt User For A Choice Of Ope

February 12, 2011 at 16:20:26
Specs: Windows XP, 2.0 GHz, 512MB
How can I have this batch file prompt the user to select one of the choices below?
1. Terminate program at this point.
2. Perform this operation.
3. Skip this operation and go to the next operation.

Thank you.

Copy.bat
-----------------------------------------------------------------
@ECHO OFF
echo "Enter FolderName"
set /p FolderName=

xxcopy "D:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "D:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE D
SLEEP 2000

xxcopy "F:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "F:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE F
echo %FolderName% REPLACEMENT IN Program Files ON LOCAL COMPUTER COMPLETE.

::-----------------------------------------------------------------------
:: NEED A PROMPT HERE TO SELECT ONE OF THE FOLLOWING
:: 1. TERMINATE PROGRAM
:: 2. REPLACE %FolderName% IN Program Files ON DRIVE H
:: 3. SKIP DRIVE H AND GO TO REPLACE %FolderName% IN Program Files ON DRIVE H
::-----------------------------------------------------------------------

echo TO TERMINATE CLOSE THIS WINDOW.
echo TO CONTINUE REPLACEMENT OF %FolderName% ON REMOTE DRIVE H
PAUSE

xxcopy "H:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "H:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE H
PAUSE
--------------------------------------------------------------------------------------


See More: Batch File To Prompt User For A Choice Of Ope

Report •

#1
February 13, 2011 at 01:00:16
I have found a way to make the script do what I wanted. My script isn't very elegant I am sure there are better ways to write a script to achieve this. But although it may be primitive, it does what I wanted.

New Copy.bat
-----------------------------------------------------------------

I have found a way to make the script do what I wanted. My script isn't very elegant I am sure there are better ways to write a script to achieve this. But although it may be primitive, it does what I wanted.

New Copy.bat
-----------------------------------------------------------------
@ECHO OFF
echo "Enter FolderName"
set /p FolderName=

xxcopy "D:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "D:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE D
SLEEP 2000

xxcopy "F:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "F:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE F
echo %FolderName% REPLACEMENT IN Program Files ON LOCAL COMPUTER COMPLETE.

::-----------------------------------------------------------------

setlocal

echo T - TERMINATE Operation
echo P - PROCESS Drive H
echo S - SKIP Drive H Continue on to Drive M

set /p option=[1,2,3]?

if "%option%"=="T" goto TERMINATE
if "%option%"=="P" goto PROCESS_H
if "%option%"=="S" goto SKIP

echo Invalid option
goto :TERMINATE

::-----------------------------------------------------------------

:PROCESS_H

xxcopy "H:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "H:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE H
SLEEP 2000

goto SKIP

:SKIP

::-----------------------------------------------------------------

setlocal

echo T - TERMINATE Operation
echo P - PROCESS Drive H

set /p option=[1,2]?

if "%option%"=="T" goto TERMINATE
if "%option%"=="P" goto PROCESS_M

echo Invalid option
goto :TERMINATE

::-----------------------------------------------------------------

:PROCESS_M

xxcopy "M:\Program Files\%FolderName%\" /RMDIR /YY
xxcopy "C:\Program Files\%FolderName%\" "H:\Program Files\%FolderName%\" /KS /H /E /YY /R

echo REPLACED %FolderName% IN Program Files ON DRIVE M
goto :TERMINATE

:TERMINATE
echo TERMINATING PROGRAM IN 10 SECONDS
SLEEP 10000
EXIT


Report •
Related Solutions


Ask Question