Jump to content

Let the user what to install or timeout


Recommended Posts

I've been reading some threads regarding this issue, but none of them convinced me on how they work. Here's what i want to do: execute a cmd file in runoncex that prompts the user with 4 different otions of software to install, let's say

1 Antivirus1

2 Antivirus2

3 Antivirus3

4 Antivirus4

If user types "1" and hits enter, then Antivirus1 will be installed and exits cmd, if "2" is pressed Antivirus2 will be installed and cmd will exit, and so on.........

But, if no key is pressed within 20 seconds, then setup must default to option 1 and install Antivirus1 & exit cmd, then continue with the rest of setup. Is there a tool to make this in an easy way?

TIA

Link to comment
Share on other sites


if you use this choice.exe instead http://www.usfamily.net/web/wpattinson/wil...util/choice.zip then you can do it like that:

(pressing enter with no number, or pressing escape, or waiting 20 seconds will all choose option 1 as well)

@echo off
echo 1) install something av
echo 2) install another av
echo 3) install somecorp av
echo 4) install nogood av
choice /C1234 /E /t1,20

if errorlevel 255 goto av1
if errorlevel 4 goto av4
if errorlevel 3 goto av3
if errorlevel 2 goto av2
if errorlevel 1 goto av1
if errorlevel 0 goto av1

:av1
echo installing something av
rem (setup.exe here)
goto end

:av2
echo installing another av
rem (setup.exe here)
goto end

:av3
echo installing somecorp av
rem (setup.exe here)
goto end

:av4
echo installing nogood av
rem (setup.exe here)

:end

Link to comment
Share on other sites

Great! Thanks!

Testing.....

It worked as expected :D thaks again.

You're welcome :)

Choice.com would work, but this clone has a few more functionnality and it's free... (choice.com coming from an old ms-dos -technically- would still require a license of the os it's coming from too... even though i can't see someone getting sued for that...)

Why not :)

Link to comment
Share on other sites

@crahak

Maybe true, but I believe that you can do without choice.com. It's existance is dying for a reason. It's like the old goto and gosub commands are dead amongst the latter lauguages. I realize batch lauguage is restrictive, but I think that your dependency on choice.com is showing alot.

BTW, do not let me take away, how helpful you are, towards people in need.

Keep the good spirit going.

Link to comment
Share on other sites

Oh, don't worry, no issues...

Choice.com is only needed because the scripting languages' limitations (there is no easy/proper way to have a timeout on the keystroke otherwise). The if goto is indeed a very old and ugly way of doing things, but until we can do select case (errorlevel) in a batchfile (although it would work in a vbscript), we're pretty much stuck with it. most scripting languages don't offer too much when it comes to console input unfortunately... And I think choice.com is "dying" mostly because nobody wants a dos-based install nowadays (they'd rather have a windows GUI setup made with something like autoplay media studio instead) along with pretty much all the other good old dos/command line utilities.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...