• 0

.bat file question?


Question

For this semester we are coding in Assembly and I have all the files required. But the only problem is I would like to create a .bat file that prompts for a file name.

as of right now I have a .bat file as follows

cd C:\Documents and Settings\Owner\Desktop\myASM\Software
ml /c /coff /Zi example.asm
link /debug /subsystem:console /entry:start /out:example.exe example.obj io.obj kernel32.lib

The first line set the command prompt within the correct folder for operation.

The second line compiles the .asm file into an .obj file.

The third line takes the .obj file and produces a .exe file.

How can I set variables in .bat files to prompt me for input? Or is this possible?

Thnx

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

C:\>example.bat testfile

cd C:\Documents and Settings\Owner\Desktop\myASM\Software
ml /c /coff /Zi %1.asm
link /debug /subsystem:console /entry:start /out:%1.exe %1.obj io.obj kernel32.lib

All %1's would be replaced with 'testfile'. You can use multiple parameters, and refer to them using %2, %3, etc.

HTH

Link to comment
Share on other sites

  • 0

thanks alot thats exactly what I was looking for

but how can I use that without the command prompt?

meaning not having to type C:\Compile and Link.bat blahfilenamehere

just a simple double-click and maybe a prompt or does CMD not support that?

Link to comment
Share on other sites

  • 0
thanks alot thats exactly what I was looking for

but how can I use that without the command prompt?

meaning not having to type C:\Compile and Link.bat blahfilenamehere

just a simple double-click and maybe a prompt or does CMD not support that?

586471130[/snapback]

Norton Utilities for DOS used to have a batch enhancer (BE.EXE) that did this sort of thing. I don't think there is any internal support for it though.

Link to comment
Share on other sites

  • 0
but how can I use that without the command prompt?

586471130[/snapback]

@echo off

set/p "asm=Enter filename without extension: "

cd C:\Documents and Settings\Owner\Desktop\myASM\Software
ml /c /coff /Zi %asm%.asm
link /debug /subsystem:console /entry:start /out:%asm%.exe example.obj io.obj kernel32.lib

Link to comment
Share on other sites

  • 0
@echo off

set/p "asm=Enter filename without extension: "

cd C:\Documents and Settings\Owner\Desktop\myASM\Software
ml /c /coff /Zi %asm%.asm
link /debug /subsystem:console /entry:start /out:%asm%.exe example.obj io.obj kernel32.lib

586471382[/snapback]

Thanks, you solved the problem. I got a quick question though.

How come whenever I execute the program from Windows Explorer once my values are entered it blazes right through anyother text and the Press any key to Continue dialog. But whenever I launch from CMD prompt the program runs as developed??

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.