| 1. |
Solve : Batch file to autoselect option after 1 minute? |
|
Answer» Hi all. Many years ago I had a similar question and it was answered. I can't find my old profile or the old post. I have code from another person in the forums and now I want to add a line so that it auto selects "N" after 60 seconds. I remember the command being so easy. The ERRORLEVEL environment variable is set to the index of theQuote if /DI don't recognise the /D switch for IF. Quote from: BC_Programmer on January 16, 2018, 11:32:19 AM from CHOICE /?Reading is FUN!Quote from: Salmon Trout on January 16, 2018, 12:36:32 PM I don't recognise the /D switch for IF.Quote from: Squashman on January 16, 2018, 02:09:02 PM Reading is FUN! thanks guys but I think you missing the point. My first post, the code works fine. I don't really want to use choice.exe but if I have to use it then how do i make my bat file work? Squashman gave me a code using choice.exe and it works. Now where do I go from there? I've even tried taking out the top line of my code and inserting squashman's code and using the /I switch but it doesn't work because obviously it can't find c. There is a way to not use choice.exe and I would prefer that way but if i have to use choice.exe, how do I select a choice so the bat file runs the commands after Y and N?Quote from: BC_Programmer on January 16, 2018, 11:32:19 AM from CHOICE /? Of course I haven't forgotten about you. How do I program the bat file to carry on and select y or n? When I press Y or N the bat file closes. Can you show me the code?I finally found the correct solution on google after a long time of searching. Here is my complete bat file. Please note the Error as proposed by bc_programmer. Code: [Select]@ECHO OFF :choice choice /C YN /D N /T 60 /M "Are you sure you want to continue?" IF errorlevel 2 goto :somewhere_else IF errorlevel 1 goto :somewhere pause goto :choice |
|