-3

I would like to quick modify a simple .bat to insert an input file of choice in the executing string. Namely, the simple .bat string is:

java -cp myapp.jar infile

Wonder if there is a smart way to send the infile from Win explorer (or other file manager) to such string, without doing it via cmd-line-typing everytime? Besides, java might need additional controls, so in a properly prepared .bat the only variable will be the infile-name at end of string. Thanks for a thought in advance!

Leo
  • 11

1 Answers1

1

Here is the ultimate solution (thanks to all contributors): creating an exec string with the infile-name variable under the needed file association's Command key in the registry. Create the association and descendent keys if necessary.

Windows Registry Editor Version 5.00

HKEY_CLASSES_ROOT\SystemFileAssociations.myfiletype\shell\subtitle @=Open with Myapp...

HKEY_CLASSES_ROOT\SystemFileAssociations.myfiletype\shell\subtitle\command @="C:\sys_path_to\javaw.exe" -cp "C:\path_to\Myapp.jar" org.appropriate.java.class %1

where %1 is the variable for infile-name for .myfiletype passed via shell context menue (specified in subtitle key). This fully takes over the initially bat-written string. Needed to replace java.exe with javaw.exe to run it shell-less.

Works just neatly, awesome.

Leo
  • 11