I'm would like to know how I can open a specific file using a specific program with a batch file. So far, my batch file can open the program, but I'm not sure how to open a file with that program.
@echo off
start wgnuplot.exe
I'm would like to know how I can open a specific file using a specific program with a batch file. So far, my batch file can open the program, but I'm not sure how to open a file with that program.
@echo off
start wgnuplot.exe
@echo off
start %1
or if needed to escape the characters -
@echo off
start %%1
That program would need to have a specific API that you can use from the command line.
For example the following command uses 7Zip to extract a zip file. This only works as 7Zip has an API to do this specific task (using the x
switch).
"C:\Program Files\7-Zip\CommandLine\7za.exe" x C:\docs\base-file-structure.zip
You can simply call
program "file"
from the batch file for the vast majority of programs. Don't mess with start
unless you absolutely need it; it has various weird side-effects that make your life only harder.
The The point here is that pretty much every program that does something with files allows passing the name of the file to do something with in the command line. If that weren't the case, then you couldn't double-click files in the graphical shell to open them, for example.
If the program you're executing is a console application, then it will run in the current console window and the batch file will continue afterwards. If the program is a GUI program then the batch file will continue immediately after starting it.