Adding default command line options when opening a particular filetype

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

Posted 2011-03-12T18:46:50.593

Reputation: 178

Answers

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

Posted 2011-03-12T18:46:50.593

Reputation: 111 572

1I don't have the edit permission necessary to correct it myself but I think you mean "pane", not "pain". Not trying to be a grammer nazi or anything, just trying to help. +1 – None – 2011-03-12T22:11:37.547

@Spooky Action - I have the knowledge, lack the grammar skills - I never take offence! ... I do try, but look through my other answers, you will find loads more!... But, I thought anyone can edit now :S – William Hilsum – 2011-03-12T22:22:27.020

When I tried to edit the post it complained that my edit was too short? I wasn't sure if that's a permissions issue or just how the edit option works, either way I couldn't fix it myself. – None – 2011-03-13T00:09:47.413

Ahh - I had something similar when I tried to change something on Stack Overflow... I ended up adding white space to the end in order to allow the change. Good point and I will try to open a meta question about it. – William Hilsum – 2011-03-13T00:11:40.693

7

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

Posted 2011-03-12T18:46:50.593

Reputation: 171

-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\""

Douglas.Shatterly.Jr

Posted 2011-03-12T18:46:50.593

Reputation: 1