Saved Bookmarks
| 1. |
Solve : BATCH FILE + sleep command??? |
|
Answer» I have a batch file, and part of it, the user has the choice to either, shutdown, hibernate, logoff or sleep. I have all of the commands except for the sleep command...is there one? I have been un-able to find one @echo offThat's not how you spell "choice", and what happens after the set /p line if the user just presses ENTER? Or anything other than 1 to 5? Hi behzad-007, Since OP is using Win7 other than XP, I think it's better to use choice command. Because it's COMPLICATED to ensue user's legal input when using set /p command. Quote from: CN-DOS on August 14, 2011, 05:50:31 AM it's complicated to ensue user's legal input when using set /p command. No it isn't. At least not in this case. The use of quotes around the VARIABLES will avoid an error after a null input and a final GOTO after the tests for legal characters can redirect the user to make a further attempt. Code: [Select]:loop set/p ch="Your choice [1,2,3,4 or 5] >" if "%ch%"=="1" goto shutdown if "%ch%"=="2" goto restart if "%ch%"=="3" goto logoff if "%ch%"=="4" goto sleep if "%ch%"=="5" goto lock echo. echo Enter 1,2,3,4 or 5 only! echo. goto loop Quote No it isn't. At least not in this case. Yes, I agree. We do have METHOD to filter the input. But not your code. Did you tried input only a double quotation mark "Quote from: CN-DOS on August 14, 2011, 06:12:05 AM Yes, I agree. We do have method to filter the input. But not your code. Did you tried input only a double quotation mark " That's a good one. The sleep command that "behzad-007" gave me (rundll32.exe powrprof.dll,SetSuspendState 0,1,0) hibernates my computer! Is this ment to happen?? Can SOMEONE please help me...the sleep commands I have been given hibernate my computer. I am running Windows 7They haven't been back in 7 years...Quote from: athman8 on April 04, 2018, 07:10:16 AM I use a batch file to start up a few of the programs I need running in the background. Up until now, I had used the pause command to execute it after some of the other start-ups finished. I would prefer to use the wait or sleep commands but they do not appear to be included in Windows 7.Anybody know how to put those commands back in, or a different method that achieves the same results?Timeout |
|