20

For some reason lately I've experienced this issue with trying to set a default application for an extension. The most common ways are the following:

  1. Right Click > Open With > Choose Default Program This opens a dialog window with the option to browse any application to use for one-time only OR (by checking the appropriate checkbox) this would effectively set the default application for the selected filetype.

  2. Control Panel\Programs\Default Programs\Set Associations This settings page allows you to set the default program for every known filetype. Just as in option #1, you select the "change program" button and from the dialog window you selected the new default application

For many windows users this is nothing new, the problem is what about when the application I want doesn't appear in the options? I even browse and find the .exe file I want and select it and still it does not appear as an option.

How do I get the application to appear as an option so that I can set it as the default application?

37

After some googling I found an answer along with other forums with no sufficient answer so I thought this would make for a helpful post.

STEP 1

First you need to get the associated name of your file type. In the command prompt (be sure to run as Admin) run the following

  • assoc {filetype}

    For example:

    • assoc .php

      Should output .php=phpfile <- this is what you need for the next part

STEP 2

Once you have the filetype association that you would like to change you will run the ftype command on it

  • ftype {file_association}="absolute-path-to-application" "%1"

    For example:

    • ftype phpfile="C:\Dropbox\ST3\sublime_text.exe" "%1"

That command effectively added Sublime Text as a recommended application for phpfile type associations. Now when I use the normal windows methods for settings a default application it appears without even having to browse for it.

SUCCESS!

Full description can be found here

BONUS POINTS:

If you get a response like the following: File association not found for extention then you simply need to create an association for that extension with the following:

assoc .{XXX}={filetype}

For example:

assoc .cls=javaclass

Once the association is made which you can verify using the steps above, then you can proceed with associating it to a default application.

  • Open to additions but currently having trouble with setting .md files to Sublime Text using this method. For some reason it won't come up as an option even though the CLI inserts appear to work fine – Xtremefaith Nov 20 '14 at 19:09
  • 2
    Changing the handling of .scr files was only possible when the ftype command was issued in an administrator command line. – Janosch Feb 3 '17 at 14:10
  • @Janosch thank you for your comment. it's not only for .src. Xtremefaith, please add it to response - thatone should run cmd as Administrator to do that. – Line Oct 12 '17 at 10:44
  • 1
    Good answer but seems to work only for certain programs: Those which are properly "registered" with Windows, i.e. those which show up under window-s-settings, apps, "Defaults Apps", main pane at bottom "Set defaults by app". I managed to follow the instructions above and my "bad" app now shows in the context-menu on right-click but does not open when I click on that. – Martin Zaske Oct 7 '18 at 12:12
  • Used it for .c (and .tgz) files. That Visual Studio didn't want to give them up to SublimeText (same with .cc)! All works now! I had to restart PC after given steps. – Brambor Nov 21 '18 at 20:41
4

TFeldt posted this solution in the Sublime Forum (link):

  1. Open
  2. Navigate to HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command Verify that the path is accurate, correct it if it is not. Exit regedit.
  3. Open task manager via ctrl+alt+del, kill explorer.exe, go to run and type explorer.exe (or skip this step and simply reboot).
  4. Now attempt the same thing, right click a text file, open with, navigate to sublime, and it should now appear in the list of available applications.

The problem that I had was that the path wasn't updated when I changed to ST3 from ST2.

  • Step number two did it for me. The path was not valid after an update to the app. Manually editing the registry entry worked. – subjectivist Dec 14 '16 at 20:51
  • This solved my issue : I had uninstalled Notepad++ x64 and re-installed Notepad++ x32. The registry was not up to date for some reason. – François Verry Sep 19 '18 at 15:22
2

Thanks for all the help. I recently installed Sublime Text 3 on Windows 7 and it wasn't allowing me create certain file associations.

I had to use an elevated command prompt and the command ftype to do add the file associations.

For anyone interested in a speedy fix for common web-development files just run these commands individually (command console as administrator and from root C:):

ftype phpfile="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"

ftype CSSfile="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"

ftype txtfile="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"

ftype JSFile="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"

ftype xmlfile="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"

The confirmation message for each should read something like this=:

phpfile="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"

You get the idea... Now you can use these commands for any filetype and program.

Now all these filetypes should appear in the File Association (open with) dialog.

Not to drone on, but to add Sublime 3 to the right-click context menu here's a great fix that works well: http://wordpress-corner.com/add-open-sublime-text-3-windows-explorer-context-menu/

  • 1
    This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill Jan 1 '16 at 18:06

protected by Community Dec 28 '18 at 17:36

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.