Sybux
asked on
text menu with default option and timeout in a shell script
Hi,
I'd like to write a little shell script which ask the user to chooce between n choice and I want that the program go on after 30 seconds for example if the user didn't choose anything.
in batch cmd I was using the choice command but as it is for beeing run under windows PE 3.0 dos command are very poor.
Thx in advance
I'd like to write a little shell script which ask the user to chooce between n choice and I want that the program go on after 30 seconds for example if the user didn't choose anything.
in batch cmd I was using the choice command but as it is for beeing run under windows PE 3.0 dos command are very poor.
Thx in advance
Here is a site with a workaround for the "missing" choice command in Windows PE: http://www.msfn.org/board/topic/117000-pe-20-batch-menu/
Since it sounds like you may already have the script working using choice in another version of Windows you should be able to easily modify what you have using the code on the site.
Since it sounds like you may already have the script working using choice in another version of Windows you should be able to easily modify what you have using the code on the site.
ASKER
it's nearly working except that the wscript.stdin is blocking the execution of the script as it's waiting for an input
It will wait max of 30 sec or until user types in 1-5 and ENTER.
ASKER
no, it wait until I press a key. I'm surprise as you.
You can still download choice.exe. Here is a solution posted back a bit: https://www.experts-exchange.com/questions/21658438/VBScript-or-Batch-file-to-create-timeout-delay.html
ASKER
I can't choice is a 16bits application and can't run under winPE (only 32bits)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
WScript.Echo ("Select an option:");
WScript.Echo ("\t1. Option 1");
WScript.Echo ("\t2. Option 2");
WScript.Echo ("\t3. Option 3");
WScript.Echo ("\t4. Option 4");
WScript.Echo ("\t5. Option 5");
var tm = new Date().getTime();
var input = "";
while (!(input = WScript.StdIn.Read(1)).mat
WScript.Echo(input);