0
:prompt
    set /p "asm_file_path=Enter full path name of asm file:"
pause

rem Validate the file path
:validate
    if not exist %asm_file_path% (
        echo Error! %asm_file_path% does not exist. Please enter valid file
        echo.
        goto prompt
    ) else (
        echo File found. Continuing...
        echo.
    )

I am simply trying to get a user input and store it into var asm_file_path. But for some reason the program goes into an infinite loop of Error! because the var is equal to " ". I've tried How to get two or more commands together into a batch file and How to read input from console in a batch file? and even the dos guide, but i just can't see what is wrong here.

Edit The program does not let me enter anything. I am using Windows 98.

Community
  • 1
  • 1
JShade01
  • 153
  • 12
  • The question is: what do you enter in the prompt, and does this path exist; and I would write `if not exist "%asm_file_path%"` to avoid trouble with paths containing whitespaces (I'd also add the quotes in the `echo`)... – aschipfl Oct 05 '15 at 20:44
  • I tested and your code as written works on my Windows 10 machine. Maybe your file doesn't exist. Or maybe the path isn't getting entered. (Are you redirecting the input from somewhere?) You'll have to give more information. – jimhark Oct 05 '15 at 20:44
  • it doesnt give me a chance to enter anything. And im using windows 98. – JShade01 Oct 05 '15 at 20:50
  • Windows **98**? Sure? The `/P` and `/A` switches have been added to the `SET` command [since Windows NT/2000](http://www.computerhope.com/sethlp.htm). – JosefZ Oct 05 '15 at 21:10
  • @JosefZ Yes i just found a page that told me. You should post as answer so i can close this question. – JShade01 Oct 05 '15 at 21:14

1 Answers1

1

Are you sure you are using Windows 98? I feel that the /P and /A switches have been added to the SET command since Windows NT/2000.

JosefZ
  • 28,460
  • 5
  • 44
  • 83