Question

What is the correct batch file syntax to run command-line application with arguments on windows 7?

C:\KindleGen\kindlegen.exe Htmlpage.html -c2

The bat file is in one folder with page that should be to processed.

Was it helpful?

Solution

Windows uses %1, %2, etc for the argument substitution.

Batch file test.bat contains:

c:\KindleGen\kindlegen.exe %1 -c2

Assuming the -c2 should always be applied

Call it with:

test somefile.html  

If you need to run from the GUI, you can drag the .bat file to your desktop and double click it.

If the file to be processed is always the same, then you don't need the command line args, just put the complete command line in the bat file:

c:\KindleGen\kindlegen.exe Htmlpage.html -c2

If you need to get the user's input for a file name, you could have the .bat ask for it like this:

echo off
set /p fileName=Enter file name:
c:\KindleGen\kindlegen.exe fileName -c2
set /p done=Finished. Press enter...

When you click on that it will open a command window and wait for input, run the command, then wait for enter before closing the command window. Take that last line out if you want it to just close when done.

If you need a script that runs the command for all .html files in the current folder use:

echo off
for %%c in (*.html) do c:\KindleGen\kindlegen.exe %%c  -c2

OTHER TIPS

Try:

start "" "C:\KindleGen\kindlegen.exe" "Htmlpage.html" -c2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top