8

I'd like to make it so that whenever I open a particular file type (by double clicking it in explorer) it always opens the associated program with particular command line options.

So, for example, when double clicking a .tex file I want it to not only open it with emacs (which is easy to set up just by going into "Open With"), but run emacs with the command line option "-fs".

What's the easiest way to do this?

Thanks

dbdkmezz
  • 198

3 Answers3

8

Looking under the hood at what Nirsoft FileTypesMan does, you can do the same thing manually as follows:

  1. Look in

    HKEY_CLASSES_ROOT\.ext
    

    at the (Default) value, for whatever file extension .ext you care about. Call that value {class_for_ext}.

  2. Look in

    HKEY_CLASSES_ROOT\{class_for_ext}\shell\open\command
    

    at the (Default) value. That's the command line which Windows Explorer will run, and which FileTypesMan will let you edit.

HughG
  • 181
4

I would say that the easiest tool is Nirsoft FileTypesMan.

Launch it and find the extension you want to modify.

In the lower pane, find the action and modify it to either emacs.exe -fs %1 or emacs.exe %1 -fs

... Assuming Emacs.exe is the program name. Also, having never used it, I am not sure what order to provide the arguments. %1 is the file name, so use whichever one works.

William Hilsum
  • 117,648
-1

Thanks for pointing me in the right direction. I made a reg file script to for excel so it always opens in multiple exe instances vs the new default single instance. /X is the option for this in MS office apps. "excel.exe /X" in shortcut, and ".... excel.exe" /X "%1" in registry.

From win7:

[HKEY_CLASSES_ROOT\xls_auto_file]
@=""
"EditFlags"=hex:00,00,01,00

[HKEY_CLASSES_ROOT\xls_auto_file\shell]

[HKEY_CLASSES_ROOT\xls_auto_file\shell\open]

[HKEY_CLASSES_ROOT\xls_auto_file\shell\open\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE\" /X \"%1\""

[HKEY_CLASSES_ROOT\xlsx_auto_file]
@=""
"EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\xlsx_auto_file\shell]

[HKEY_CLASSES_ROOT\xlsx_auto_file\shell\open]

[HKEY_CLASSES_ROOT\xlsx_auto_file\shell\open\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE\" /X \"%1\""