4

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.

marked as duplicate by user477799, Run5k, Pimp Juice IT, music2myear, Twisty Impersonator Apr 7 '17 at 18:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 '17 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). – music2myear Apr 7 '17 at 16:08
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.

  • Could this script be adapted to work for other default programs and file extensions? – Steven M. Vascellaro Mar 5 '17 at 22:06
2

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

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