Go Back   Computer Forums > General Computing > Software and Operating Systems
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 08-22-2011, 10:58 PM   #1
BSOD
 
Join Date: Aug 2011
Posts: 45
Default can someone help me with a batch file?

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
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
__________________

crashoveride is offline   Reply With Quote
Old 08-23-2011, 08:07 AM   #2
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,944
Default Re: can someone help me with a batch file?

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".
__________________

strollin is offline   Reply With Quote
Old 08-23-2011, 10:48 PM   #3
BSOD
 
Join Date: Aug 2011
Posts: 45
Default Re: can someone help me with a batch file?

Thanks it work wonders, Im still a learning Operating Systems, where whould I put a cancel choice for the shutdown and convert commands?
crashoveride is offline   Reply With Quote
Old 08-24-2011, 07:12 AM   #4
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,944
Default Re: can someone help me with a batch file?

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
strollin is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 09:57 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0