Computing.Net > Forums > Disk Operating System > Need help on a batch file!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need help on a batch file!

Reply to Message Icon

Name: Paul
Date: July 22, 2003 at 10:06:13 Pacific
OS: Win Xp Home
CPU/Ram: P3 1.2
Comment:

here ie is. I want to give the user a choice for which program they would like to run. Please help!
----------------

@echo OFF

set LOG = ProgramChoiceLOG.txt

:menu
echo *******************************
echo * choose Your Program(s) *
echo *******************************
echo * *
echo * 1 Access *
echo * 2 Word *
echo * 3 Excel *
echo * 4 All the Above *
echo * *
echo *******************************


rem code helper
echo before input


:input
set INPUT=
set /P INPUT=
if "%input%" =="" goto menu
echo %input%
pause

rem code helper
echo before the loop

pause

goto loop

:loop

(
if "%input%" =="1"
start access.exe >> %LOG%
echo loop1
pause

if "%input%" =="2"
start winword.exe >>"%LOG%"
echo loop2
pause
if "%input%" =="3"
start EXCEL.exe >> "%LOG%"
echo loop3
pause

if "%input%" =="4"
start EXCEL.exe
start access.exe
start winword.exe >> "%LOG%"
echo loop 4

rem code helper
echo error handler
pause

if "%input%" =="" goto menu

else goto error
)

:error
echo Not a valid Response! >> "%LOG%"
goto menu
pause




Sponsored Link
Ads by Google

Response Number 1
Name: beama
Date: July 22, 2003 at 12:12:26 Pacific
Reply:

personally I would use "chioce" type choice/? for help on this at the command prompt


0

Response Number 2
Name: beama
Date: July 22, 2003 at 14:14:21 Pacific
Reply:

this works in xp pro
@echo OFF

set LOG = ProgramChoiceLOG.txt

:menu
echo *******************************
echo * choose Your Program(s) *
echo *******************************
echo * *
echo * 1 Access *
echo * 2 Word *
echo * 3 Excel *
echo * 4 All the Above *
echo * *
echo *******************************


echo before input

set INPUT=
set /P INPUT=
if "%input%" =="" goto menu
pause

echo before the loop

pause


echo here
path = "C:\Program Files\Microsoft Office\Office"
if("%input%" =="1") then
ECHO TEST
start msaccess.exe
echo loop1
pause
end if


0

Response Number 3
Name: beama
Date: July 23, 2003 at 03:05:59 Pacific
Reply:

here you go Paul this works on 98se not tested on xp pro but I have used choice in xp pro before with no problems


@echo OFF


:menu
echo *******************************
echo * choose Your Program(s) *
echo *******************************
echo * *
echo * 1.. Access *
echo * 2.. Word *
echo * 3.. Excel *1
echo * 4.. All the Above *
ECHO.
ECHO.
ECHO VALID ENTRIES ARE 1, 2, 3 OR 4 ONLY
echo * *
echo *******************************
ECHO.
ECHO.

choice /c:1234/N "Enter choice "

IF ERRORLEVEL == 4 GOTO ALL
IF ERRORLEVEL == 3 GOTO EXCEL
IF ERRORLEVEL == 2 GOTO WORD
IF ERRORLEVEL == 1 GOTO ACCESS


:ACCESS
start msaccess.exe
goto end

:WORD
start winword.exe
goto end

:EXCEL
start excel.exe
goto end

:ALL
start EXCEL.exe
start MSaccess.exe
start winword.exe
goto end

:end
cls


0

Response Number 4
Name: paulpobursky
Date: July 23, 2003 at 09:16:41 Pacific
Reply:

Here is my finished product. I was just having a lot of QUOTES problems thats all, but I liked you layout a lot more thn mine it;s mre readable
============================================

@echo OFF

set LOG = ProgramChoiceLOG.txt

:MENU
cls
echo *******************************
echo * choose Your Program(s) *
echo *******************************
echo * *
echo * 1 Access *
echo * 2 Word *
echo * 3 Excel *
echo * 4 All the Above *
echo * *
echo * Q to Quit *
echo * *
echo *******************************
echo.

set INPUT=
set /P INPUT=

rem The path below should be the same on all personal computers
rem path = "C:\Program Files\Microsoft Office\Office"

if "%input%" =="" goto MENU
if %input% == 1 goto ACCESS
if %input% == 2 goto WORD
if %input% == 3 goto EXCEL
if %input% == 4 goto ALL
if %input% == Q goto QUIT
if %input% GEQ 5 goto ERROR

:ACCESS
start msaccess.exe
goto MENU

:WORD
start winword.exe
goto MENU

:EXCEL
start excel.exe
goto MENU

:ALL
start msaccess.exe
start winword.exe
start excel.exe
goto MENU

:QUIT
echo.
echo Thank you Goodbye
echo.
echo.
pause
exit

:ERROR
echo.
echo You MUST enter one of the choices listed on the menu!
echo.
pause
goto MENU


0

Response Number 5
Name: Tamica Webb
Date: July 23, 2003 at 13:50:52 Pacific
Reply:

Recently, I typed a list of commands and now my instructer wants me to create a batch file using notepad;the commands are COPY, CD, REN, MD, REM, DEL, DIR. Maybe you can help me understand what she wants by giving me an example then I'll do the rest. Thank you


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Need help on a batch file!

I need help on DOS batch file www.computing.net/answers/dos/i-need-help-on-dos-batch-file/1129.html

I need help on DOS batch file www.computing.net/answers/dos/i-need-help-on-dos-batch-file/1130.html

need help writing batch file www.computing.net/answers/dos/need-help-writing-batch-file/4728.html