Osama Nabih
Osama Nabih

Reputation: 63

How can I make a batch file that automatically builds, links and executes a .asm file?

I am working with DosBox emulator in my university. We build .asm files with MASM. I am extremely tired of having to build my .asm file every time with masm, then pressing enter 4 times, then entering link .obj, then enter 4 times. Then running the actual .exe. I wanted to automate this, and after searching for a while, I understand I need to make a batch file. It currently looks like this

@echo off

set arg1=%1
masm %arg1%.asm
%SendKeys% ("echo off{ENTER}")
%SendKeys% "echo off{ENTER}"
%SendKeys% "echo off{ENTER}"
%SendKeys% "echo off{ENTER}"
link %arg1%.obj
%SendKeys% "echo off{ENTER}"
%SendKeys% "echo off{ENTER}"
%SendKeys% "echo off{ENTER}"
%SendKeys% "echo off{ENTER}"
%arg1%.exe
%SendKeys% "echo off{ENTER}"

The SendKeys part doesn't work. When I searched online I was way overwhelmed by what I've found. I just want a simple way (if there is one) to simulate the four enter key pressed I have to manually do every time.

Upvotes: 3

Views: 850

Answers (1)

Michael Petch
Michael Petch

Reputation: 47573

You can place a semicolon ; on the end of masm.exe and link.exe command lines to make the programs use the default file names for the prompts.

Upvotes: 5

Related Questions