Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dos batch files
#1
i dont know if i posted this in the appropiate section but i need help figuring this out. in class, its over -- i passed, we spent 2 weeks playing w/batch files. today we tried to do one but the teacher didnt get it to work, plus i was reading up on the CHOICE batch file command. here is the simple batch file:

@echo off
cls
choice /n /c:123 Pick A Number (1, 2, 3)
if errorlevel 1 goto one
:one
goto end
:end

why would i get only a cursor instead of a prompt to pick a number?
here are 10 types of people, those that understand binary & those that dont. . .
Reply
#2
What operating system are you using? It seems to work for me:
Code:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>choice /n /c:123 Pick A Number (1, 2, 3)
Pick A Number (1, 2, 3)2

c:\>exit
Reply
#3
i tried it from the command prompt in XP & i tried it from a DOS RAMdrive disk.
here are 10 types of people, those that understand binary & those that dont. . .
Reply
#4
I've got a hunch. Type choice at the command prompt and see what it says.

I use Windows XP, but I also have a dead Win98 install in another partition, and it's windows and windows\command directories are on my PATH environment variable... Maybe that's why choice is working for me... Maybe XP doesn't support the choice command.

If that's the problem then all you'd have to do is get a copy of choice.com. It should be in the Windows\COMMAND directory of a Win9x install (if you can find a comp with one), or the DOS directory for msdos and Win3.x. Or I can send it to you if you want, it's tiny (about 5kb).
Reply
#5
One weird thing I remember about batch files is that errorlevels have to go in reverse order.

e.g.
Code:
@echo off

choice /n /c:123 Pick A Number (1,2,3)

if errorlevel 1 goto one
if errorlevel 2 goto two
if errorlevel 3 goto three

:one
   echo cool
goto end

:two
   echo neet
goto end

:three
   echo Wow!
:end
will give the result "cool" each time 1, 2, or 3 is pressed. But this (the errorlevels reversed):
Code:
@echo off

choice /n /c:123 Pick A Number (1,2,3)

if errorlevel 3 goto three
if errorlevel 2 goto two
if errorlevel 1 goto one

:one
   echo cool
goto end

:two
   echo neet
goto end

:three
   echo Wow!
:end
will give a different response for each key.
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#6
ok, i have the choice.com file. i am in my Mircosoft RAMdrive DISK playing around. i did what you said Phydaux, still only getting a blinky cursor & i cant even ctrl + break out of it.
here are 10 types of people, those that understand binary & those that dont. . .
Reply
#7
Microsoft tech support? (j/k) Sorry, I'm stumped.

Uh.... ok, have you tested your copy of choice.com? What happens if you just run it? Did you put it in a directory that's on your PATH? or did you give the full path to choice.com in the batch file?
Reply
#8
:lol: . . . im not going to give up until i get this. i cant even do it on my other laptop that is running 2000 PRO from the command prompt. :???:
here are 10 types of people, those that understand binary & those that dont. . .
Reply
#9
i got it to work now..in my RAMdrive disk i created & saved the batch file to the DOS folder this time & ran it..it worked. why?! the path in the disk is c:\;c:\DOS..so why didnt it work on the root? i just copied the bat file to the root dir & ran it, same problem i was having before. .. .
here are 10 types of people, those that understand binary & those that dont. . .
Reply
#10
Double check that PATH really does point to where you put choice.com... from what you've told me that's all it could be.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)