can someone help me with a batch file?

Messages
45
Look at the .bat file below

Why is it that when i go to make a choice it go's strait to shutdown -s -f -t 0?

Can you also tell me of any other errors in this?

@echo off
title GDAY!
color 6
set /p name=HELLO WHATS YOUR VIEW ON THE WORLD TODAY?
echo %name%
color 2
echo The Local Time (As set in your BIOS)
time /t
date /t
pause
color 3
echo Please tell me what you think of this basic system checking tool.
pause
cls
color 7
echo Select Your Tool
choice /c:12345 /m "1=Shutdown Computer 2=Convert FAT Drive to NTFS 3=Check Your NTFS Drive 4=Tasklist 5=Test Copy"
if errorlevel 1 goto one
if errorlevel 2 goto two
if errorlevel 3 goto three
if errorlevel 4 goto four
if errorlevel 5 goto five
:eek:ne
shutdown -s -f -t 0
msg * goodbye!
:two
convert c:
pause
:three
color 4A
chkntfs c:
pause
:four
tasklist
pause
:five
color 3
copy c:\windows\system32\hal.dll c:\
pause
 
The major issue you have with this batch file is that you need to check the errorlevel from high to low, check 5 first, then 4, etc... When you check the errorlevel, the system actually checks to see if errorlevel is >= so if 5 is true, so are all errorlevels below it.

In option 1, once you issue the shutdown command then the user won't see the goodbye message, I'd reverse those 2 lines.

If this is a real bat file you wish to distribute to others, I'd advise adding to it so that when someone selects an option you tell them what will happen and offer them the chance to cancel in case the selection was accidental. This is especially true of option 2 since it is somewhat "destructive".
 
Thanks it work wonders, Im still a learning Operating Systems, where whould I put a cancel choice for the shutdown and convert commands?
 
You could do it something like this:

@echo off
title GDAY!
color 6
set /p name=HELLO WHATS YOUR VIEW ON THE WORLD TODAY?
echo %name%
color 2
echo The Local Time (As set in your BIOS)
time /t
date /t
pause
color 3
echo Please tell me what you think of this basic system checking tool.
pause
:menu
cls
color 7
echo Select Your Tool
choice /c:12345Q /m "1=Shutdown 2=Convert to NTFS 3=Check Drive 4=Tasklist 5=Test Copy Q=Quit"
if errorlevel 6 goto six
if errorlevel 5 goto five
if errorlevel 4 goto four
if errorlevel 3 goto three
if errorlevel 2 goto two
choice /c:YN /m "You are about to shutdown your computer. Are you sure"
If errorlevel 2 goto menu
echo Good-bye!
shutdown -s -f -t 0
:two
choice /c:YN /m "This command will permanently affect your computer. Are you sure"
If errorlevel 2 goto menu
convert c:
pause
goto menu
:three
color 4A
chkntfs c:
pause
goto menu
:four
tasklist
pause
goto menu
:five
color 3
copy c:\windows\system32\hal.dll c:\
pause
goto menu
:six
 
Back
Top Bottom