DOS - "Press a Key" script

  • allanmartins
  • Born
  • Born
  • allanmartins
  • Posts: 2

Post 3+ Months Ago

Hi all,

I need a script that "ask" for you to press a Key, when you press 1, it run a command line... if you press another one, it doesn´t make anything. A simple DOS script that will run everytime you turn your comp on. Simple thing, but I spend too much time programming on PHP that I´ve forgotten my Old Times doing these scripts for DOS.

Thx a lot
sorry for my horrible english... =P
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Well, a DOS "script" would be a batch file.

Simply enter the word "pause" on a single line in the batch file.
  • allanmartins
  • Born
  • Born
  • allanmartins
  • Posts: 2

Post 3+ Months Ago

adding a "pause" command will just stop the system until any key is pressed, I want that it "follow" a commando line if the Key "1" is pressed
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

You couldn't accomplish that in a batch file.

You'd have to actually code a command line application.

Perhaps you might want to look into Free Pascal (http://www.freepascal.org/), then you could use an application/batch file combo (using errorlevel trapping) to accomplish what you need :)
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

depending on what OS your using you might be able to use the CHOICE command
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

choice? what's that come with? I've not heard of that one :)
  • Sabu
  • Beginner
  • Beginner
  • Sabu
  • Posts: 47

Post 3+ Months Ago

http://www.robvanderwoude.com/choice.html
http://www.robvanderwoude.com/userinput.html
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

if you have MSDOS 6.22 you get "CHOICE.EXE" which is a command you run and it exits with an errorlevel depending on what key the user pressed. The errorlevel can then be checked through if statements in the batchfile.

I think, with Windows 95 and 98, you can pull it off the CD, but I'm not sure as I don't have an OS that old around anymore.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Ahh neat, I never used choice. Most of my work was writing my own apps, and then using the batch files to trap the error level.

From the looks of things, I was basically suggesting writing your own version of choice, hehe.

If choice will work with more recent versions (if you can get hold of it), then that will save a whole lot of time :)

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 96 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.