Jump to content

Basic DOS programming help


Recommended Posts

Hi I'd like to add a CHOICE command in my unattended xp install so I have the choice to install or not the softwares if I happen to be in front of the computer.

CHOICE Continuer avec l'installation des logiciels de base? /C:YN /T:Y,60
if errorlevel 2 goto cleanup
if errorlevel 1 goto apps
goto end

This is my code. Now this is not working and I pretty sure I know why: I'm running Windows XP and I guess all the usefull DOS commands are gone, am I right? Now anyone got an idea how I should do a simple Y/N question in command prompt so it asks:

"Do you want to install the basic softwares" [Y/N] and goes on with yes after 60 seconds.

Thanks a lot everyone, I hope a quick answer cause it's the last thing not working on my unattended cd. I used mbox before but the question box kept appearing under the command window, thus not practical. Also there is no timer with mbox.

Link to comment
Share on other sites


If there is a demand, I could code a console app that would wait for a keypress (y/n or return an errorlevel corresponding to the ascii character... or even one for each...) and a default overridable timer... It's easy stuff but as always, there has to be a demand/use for it to justify doing it (ie, won't do it for one person alone) Language... hard to say... maybe good ol' TP7 (patched unit for fast intel cpus) - just so you don't *need* the .net framework installed, runtimes, or such requirements.

Link to comment
Share on other sites

Ok, and do I have to put it in the same folder as my batch file or in the same folder it was in windows 98? (which is Windows\Command\ if I remember correctly)

@crahak scripting... programing, as long as I get my question answered. And any programmer should know how to script anyway ;)

Link to comment
Share on other sites

If you do not want to "spoil" your new M$ OS with older files, like choice.com, you could use this workaround, as found on Rob van der Woude excellent page:

http://www.robvanderwoude.com/index.html

   @ECHO OFF
   IF "%1"=="Y" GOTO Yes
   IF "%1"=="N" GOTO No
   ECHO Yes or No? Press Y or N followed by the Enter key . . .
   ECHO @%0 Y > Y.BAT
   ECHO @%0 N > N.BAT
   GOTO End
   :Yes
   ECHO You answered Yes
   GOTO End
   :No
   ECHO You answered No
   :End

but still you have the problem of waitibg 60 seconds, which can be done with this other PING trick:

For any MS-DOS or Windows version wit a TCP/IP client, PING can be used to delay execution for a number of seconds.
If specified (-w switch), PING will wait for a number of milliseconds between two PINGS before giving a time-out.


PING 1.1.1.1 -n 1 -w 60000 >NUL
will delay execution of the next command 60 seconds, provided 1.1.1.1 is not a valid IP address (I previously used -n 60 -w 1000 which should theoretically result in the same delay, but as Greg Hassler pointed out this may be highly inaccurate on some computers).

found here:

http://www.robvanderwoude.com/wait.html

jaclaz

Link to comment
Share on other sites

That's a nice workaround for choice.com for sure. as for win98, you can copy it to anyhwhere in your %path% so yes \windows\command should work fine.

As for the delay, he doesn't want a delay, he wants a time-out, and that, ping'ing will not do.

I don't see adding choice.com myself as "spoling" an install. I in fact add many very handy command line utilities to all my installs. I see it as extras (you are going to add more stuff to your windows install no matter what anyways)

I could have suggested using vbscript, but being win98... it might not be the best way (stdin.readline could have done the trick too)

As for the timeout, no scripting method that I can think of would give you that.

Link to comment
Share on other sites

Thanks a lot to you too guys, I'll take my time to look and the solution jaclaz offered, cause I'm no scripter and I need to understand what I'm doing before doing it. Looks like a good solution but Rob van der Woude's really specified that it was to be used in last resort, which may be my case lol

Anyway, I'll try to find some DOS 7.10 disks while I try his solution

Anyone know where I should put CHOICE.com on my cd so it works? The folder where my batch file is running or $OEM$\$$\Command\?

Link to comment
Share on other sites

That should work (putting it in the same spot as the script). The only thing is, I'm not sure if that choice.com does a dos version check (I don't think it does but lots of dos apps do that, although it's very easy to bypass as well if you have basic dos asm knowledge).

The only bad thing is choice.com doesn't time-out after 60 secs (unless this one is different from the other choice.com's i've tried?)

Link to comment
Share on other sites

Ok, CHOICE.com SHOULD NOT be in c:\windows\command else it tells me it is not recognised as a valid internal or external command, but it works perfect if it is directly in the folder your batch file is running. And the timer works too for 60 seconds.

@greenmachine

thanks for your link, I'll still try your solution just for fun, and the page you linked got more goodies ;)

Link to comment
Share on other sites

@crahak

I do not want to argue, but in English

"Do you want to install the basic softwares" [Y/N]and goes on with yes after 60 seconds.

is called "delayed execution of a command"

If you think it is better to call it a timeout, do it, you are free, but don't go around teaching others.

jaclaz

Link to comment
Share on other sites

No arguing guys :thumbup

There is about 1000 ways to do and call things is scripting/programming, what's important is the end result!

Thanks all for helping

P.S. I included in attachment the CHOICE.com file i found on the net, don't know if it's from version 6, 6.1, 6.22, 7 or 7.10 but anyway, it works, just copy it in EVERY directory where a batch file uses the CHOICE command and it will work!

choice.com

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...