5

How can I change the default program for a file without changing its icon? For example, I'd like some file extensions (.css, .js, .cshtml, etc.) to be opened with Sublime Text, but I want to keep the original icon that MS Visual Studio has set.

2
  • I'm not sure the proposed duplicate actually covers this question, at least the single answer that satisfied that OP. 1) That answer describes changing the default icon. This question seems to be asking about finer granularity. 2) Not changing the icon is different from setting a desired icon. Not changing it means you don't need to find or extract the icon you want to keep.
    – fixer1234
    Apr 6, 2017 at 21:07
  • 1
    To Windows it's pretty much the same thing unless you're going to muck about deep in the registry. The icon is tied to the filetype, not the extension itself (in registry icons are found in txtfile, not .txt). Apr 7, 2017 at 16:08

2 Answers 2

3

As answered by SSAURABHH on a similar question...


Default Programs Editor can do what you need:

Default Programs Editor makes it easy to fix file association settings in Windows, including context menu items, icons, and descriptions.

Screenshot

2

I have created this .reg file with some effort. It will change default program for these extensions: .js, .cs, .ascx, .aspx, .config and sets their icons to default icons for VS 2013:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SublimeText.ascx]
@="ASP.NET User Control"

[HKEY_CLASSES_ROOT\SublimeText.ascx\DefaultIcon]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Packages\\htmled.dll,1"

[HKEY_CLASSES_ROOT\SublimeText.ascx\shell]

[HKEY_CLASSES_ROOT\SublimeText.ascx\shell\Open]

[HKEY_CLASSES_ROOT\SublimeText.ascx\shell\Open\Command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\.ascx]
@="SublimeText.ascx"

[HKEY_CLASSES_ROOT\.ascx\OpenWithProgids]
"SublimeText.ascx"=""






[HKEY_CLASSES_ROOT\SublimeText.aspx]
@="ASP.NET Server Page"

[HKEY_CLASSES_ROOT\SublimeText.aspx\DefaultIcon]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Packages\\htmled.dll,4"

[HKEY_CLASSES_ROOT\SublimeText.aspx\shell]

[HKEY_CLASSES_ROOT\SublimeText.aspx\shell\Open]

[HKEY_CLASSES_ROOT\SublimeText.aspx\shell\Open\Command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\.aspx]
@="SublimeText.aspx"

[HKEY_CLASSES_ROOT\.aspx\OpenWithProgids]
"SublimeText.aspx"=""




[HKEY_CLASSES_ROOT\SublimeText.cs]
@="Visual C# Source file"

[HKEY_CLASSES_ROOT\SublimeText.cs\DefaultIcon]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC#\\VCSPackages\\csproj.dll,1"

[HKEY_CLASSES_ROOT\SublimeText.cs\shell\Open\Command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\.cs]
@="SublimeText.cs"

[HKEY_CLASSES_ROOT\.cs\OpenWithProgids]
"SublimeText.cs"=""



[HKEY_CLASSES_ROOT\SublimeText.js]
@="JavaScript File"

[HKEY_CLASSES_ROOT\SublimeText.js\DefaultIcon]
@="\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\msenvico.dll\",-223"

[HKEY_CLASSES_ROOT\SublimeText.js\shell\Open\Command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\.js]
@="SublimeText.js"

[HKEY_CLASSES_ROOT\.js\OpenWithProgids]
"SublimeText.js"=""



[HKEY_CLASSES_ROOT\SublimeText.config]
@="XML Configuration File"

[HKEY_CLASSES_ROOT\SublimeText.config\DefaultIcon]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\Xml\\Microsoft.XmlEditorNeutralUI.dll,3"

[HKEY_CLASSES_ROOT\SublimeText.config\shell\Open\Command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\.config]
@="SublimeText.config"

[HKEY_CLASSES_ROOT\.config\OpenWithProgids]
"SublimeText.config"=""



[HKEY_CLASSES_ROOT\SublimeText.cshtml]
@="ASP.NET Web Page (CSHTML)"

[HKEY_CLASSES_ROOT\SublimeText.cshtml\DefaultIcon]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Packages\\htmled.dll,9"

[HKEY_CLASSES_ROOT\SublimeText.cshtml\shell\Open\Command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\.cshtml]
@="SublimeText.cshtml"

[HKEY_CLASSES_ROOT\.cshtml\OpenWithProgids]
"SublimeText.cshtml"=""

just copy it in a text file and save it as OpenWithSublimeText.reg and double click on it.

1
  • Could this script be adapted to work for other default programs and file extensions?
    – Stevoisiak
    Mar 5, 2017 at 22:06

Not the answer you're looking for? Browse other questions tagged .