473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Shutdown Batch file?

3 New Member
@echo off
C:
set choice=
set /p choice=Do you wish to continue?
If %choice%==no GOTO SHUTDOWN
If %choice%==yes GOTO next
:next
echo It didn't work
exit
:SHUTDOWN
set choice=
set /p choice=Your computer is about to shutdown.Do you wish to continue?
If %choice%==no shutdown -a
If %choice%==yes shutdown -s -t:90
pause
exit


That is my first batch file. Ive been having some problems with it looping. It will ask eache question over and over and over again. If someone could tell me how to fix it that would be great. I use windows xp. Thanks

(p.s. if anyone has some good sites that tell how to create batch files please post)
Mar 9 '08 #1
1 7583
MindBender77
234 New Member
Try this and note that your choice of Y or N is case sensitive.
Expand|Select|Wrap|Line Numbers
  1. @echo off
  2. CLS
  3. :start
  4. cls
  5. set choice1=
  6. set /p choice1=Do you wish to continue? (Y or N)
  7. IF NOT '%choice1%'=='' set choice1=%choice1:~0,1%
  8. If '%choice1%'=='N' goto end
  9. If '%choice1%'=='Y' goto Next
  10. cls
  11. ECHO "%choice1%" is not valid please try again
  12. ECHO.
  13. pause
  14. goto start
  15. :Next
  16. cls
  17. set choice2=
  18. set /p choice2=Your computer is about to shutdown.Do you wish to continue? (Y or N)
  19. IF NOT '%choice2%'=='' set choice2=%choice2:~0,1%
  20. If '%choice2%'=='N' shutdown -a
  21. If '%choice2%'=='Y' shutdown -s -t:90
  22. cls
  23. ECHO "%choice2%" is not valid please try again
  24. pause
  25. goto Next
  26. ECHO.
  27. :end
  28. exit
  29.  
A good source of batch file info is www.computerhope.com/batch.htm
Bender
Mar 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
0
by: bj7lewis | last post by:
I have C# service(VS.NET 2002) that I want to bk up a few files when Windows is shutdown/restart(thur any of the correct ways to Shutdown/restart window) and choose to do the actual backup in a...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
3
by: tbone | last post by:
In trying to improve the throughput of a classic ASP app I wrote a few years ago, I added monitoring to the application and session start and end methods. I'm counting the total number of sessions...
6
by: eroc.spam | last post by:
Hello- I'm working with a .NET windows service that can potentially take up to 10 minutes to shutdown. I would like to make it so that SCM doesn't timeout before the service actually stops, but...
0
by: Varan | last post by:
hai, now we are using batch file for take backup at time of start services and stop services. we need option for take database backup at time 1. System Start ...
1
Inbaraj
by: Inbaraj | last post by:
Hi, I would like to know the EXE to startup and shutdown Oracle 9i database from command prompt (MS-DOS). I want to write 2 batch file one for startup the oracle9i and the other one is to stop the...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.