John Dudebro
John Dudebro

Reputation: 23

How can you open a non-specific file using a program called through a batch file?

I can find plenty of answers on the internet about how to open a specific file, e.g. http://answers.yahoo.com/question/index?qid=20080102230630AAfu5dF

However, I need to provide a way of opening a non-specific file in a program called by a batch file.

To explain, here is an example. The user has a folder with 100 files in with the .xyz extension. He wants to be able to double click on ANY file and open it in his "XYZ Viewer," but to run his XYZ Viewer he needs to run a batch file that alters his registry and then runs the actual XYZ Viewer .exe.

If you select the batch file to be the default program via the "Always use the selected program to open this kind of file" tickbox, it will open the program, but without using the standard Windows function of opening the file that instigating the running of the program.

Is there a way to run the program through the batch file and for it to both run the program and open whichever file it was that instigated the running of the program?

I suspect this is impossible, but any suggestions would be very gratefully received!

Cheers.

Edit: The program does eventually support opening a file placed as an argument to it.

My code is
reg import c:\regent\31.2.03.reg
start C:\Program\Program.exe

Upvotes: 2

Views: 342

Answers (1)

Pricey
Pricey

Reputation: 538

Does the program eventually support opening a file placed as an argument to it? In the example you linked, mspaint opens the first parameter given to it.

If your batch file isn't currently doing this, you will have to edit it to contain the batch parameter(s).

See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true for some fuller documentation on it.

Essentially you want to add %1 somewhere like:

reg import c:\regent\31.2.03.reg
start C:\Program\Program.exe %1

Upvotes: 2

Related Questions