11

If I click on a .ts (typescript) file and activate the Preview Pane in Windows Explorer, then I see a preview of the file:

enter image description here

Why? Because I set Notepad to open .ts files.

But I have .js files which I set Notepad++ to open them and I don't see a preview in the Preview Pane:

enter image description here

Question

How can I show .js files in the Preview Pane and still keep Notepad++ as this file type's default program?

I don't want to open Notepad++ with the option: Right-click > Open With.

I have Windows 7.

  • 1
    You can try winhelponline.com/blog/… – undo Mar 27 '17 at 16:01
  • @Rahul2001doesn't work also. I've found out that if there is a program registered to that extension , the preview doesn't work. – Royi Namir Mar 29 '17 at 13:34
11
+25

Follow these directions to edit the Registry and assign the Windows Text Preview Handler to the .js file extension. (Based on this How To Geek article.)

  1. Open Registry Editor
  2. Navigate to HKEY_CLASSES_ROOT\.js and make note of the content of the (Default) value. This is the ProgID to which the .js extension is registered: enter image description here
  3. Navigate to the ProgID's key. We'll find our key at HKEY_CLASSES_ROOT\JSFile
  4. Expand the key. If necessary, create a subkey named ShellEx
  5. Under the ShellEx key, create a new key named {8895b1c6-b41f-4c1c-a562-0d564250836f}. Note: According to MSDN the presence of this exact value tells Windows that this is a preview handler.
  6. Select this newly created key and set its (Default) value to {1531d583-8375-4d3f-b5fb-d23bbd169f22}. This is the ID for Windows' Text Preview Handler. enter image description here
  7. The change will take effect immediately.
|improve this answer|||||
  • 1
    It doesn't work. And I even restarted explorer.exe (windows 7 pro) – Royi Namir Mar 27 '17 at 7:15
  • 1
    @Royi Interesting. I tested this and it worked. Can you try these steps on another file type and see if the problem is isolated to .js files on your machine? – I say Reinstate Monica Mar 27 '17 at 13:03
  • I've found out that if there is a program registered to that extension , the preview thing doesn't work. – Royi Namir Mar 29 '17 at 13:34
  • @Royi Perhaps it matters what program is registered. In my testing I used an extension that was associated with a program that doesn't have its own preview handler. – I say Reinstate Monica Mar 29 '17 at 16:19
  • Yeah but my question was "and still keep Notepad++ as this file type's default program" ...... :-) – Royi Namir Mar 29 '17 at 17:14
6

Since the file contents are just plain text, you can make Explorer treat it as such. You can use Content Type and PerceivedType to achieve that. Here is how to do it:

  1. In the Registry Editor, navigate to the key related to that file type. For the file type asked, the path would be like HKEY_CLASSES_ROOT\.js.
  2. In that key, right-click the right panel and choose New > String Value.
  3. Name it as Content Type.
  4. Double click that value and set it as text/plain.
  5. Repeat the steps 2 to 4 but naming the value as PerceivedType and setting the value to text.

Restart Explorer and voilá! The file will still be associated with any editor you have set but the built-in preview feature will treat it as a text file and then show a preview.

As a side effect, if you sort/group your list in Explorer as Perceived Type it will be classified under Text file.

Note: for instance I did a test by making a .dummy and associated it with Google Chrome, the file could be previewed in the Preview Pane and double-clicking it still executed Chrome as intended.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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