Home > database >  How to write a batch script to call a .exe file? [closed]
How to write a batch script to call a .exe file? [closed]

Time:09-22

I have a .exe file (let's say it's name is XXX.exe) whose job is to clean a text file with all lines starting with %. Usually I call the .exe file in CMD as:XXX.exe clean_text.dat and it does the job.

However I want to create a batch file where the text file's name will be user input and rest everything will be done automatically. I have written a script as:

@echo off
set /p file= Enter filename:
XXX.exe file

After giving the filename (with full path), CMD flashes error saying it can't access to the input file.

I believe the last line is not correctly writtten. Can anyone provide the solution?

CodePudding user response:

Use %file% in the last line. You want the contents of variable file and not the name of the variable to be used as parameter for program XXX.exe.

  • Related