9sBlog

Fix .exe files that open in Notepad on Windows

When Windows opens every .exe in Notepad, the file association is broken. Restore it with a registry fix, boot to Safe Mode if needed, then scan for malware.

computer, laptop, notebook, 3d wallpapers

If every program on your PC suddenly opens in Notepad, or nothing runs at all, the association Windows uses for .exe files has been changed. The fix is to restore that association in the registry, and then scan for malware, because a hijacked .exe association is a classic infection symptom. This guide does both, Windows 11 first, in the order that actually gets you back to a working desktop.

What broke, and why Default apps won’t fix it

Windows decides how to open a file by its type. Normally the .exe extension points to a type called exefile, whose “open” command tells Windows to run the program directly. When something rewrites those values, every executable inherits the wrong instruction, so double-clicking a program launches Notepad, throws an “Open with” box, or shows an error like “Windows cannot find the file.” The usual causes are malware that tampers with file types, or a stray “Always use this app to open .exe files” choice.

Your first instinct is probably Settings > Apps > Default apps. That page is built for document types like .pdf and .html, and it can’t restore the native run behavior of an executable. Worse, pointing .exe at a specific program through Open with just makes every program launch with that one app. The reliable fix lives in the registry.

Restore the .exe association in the registry

The goal is to put three values back to their Windows defaults. Editing the registry directly is fine, but the safest path is to merge a small .reg file, because that keeps working even when .exe programs won’t launch.

Registry keyValue to restore
HKEY_CLASSES_ROOT\.exe (Default)exefile
HKEY_CLASSES_ROOT\exefile (Default)Application
HKEY_CLASSES_ROOT\exefile\shell\open\command (Default)"%1" %*

Open Notepad, paste the block below, and save it as fix-exe.reg with the “Save as type” set to All Files. Then double-click the file (or right-click and choose Merge) and confirm the prompt.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.exe]
@="exefile"

[HKEY_CLASSES_ROOT\exefile]
@="Application"

[HKEY_CLASSES_ROOT\exefile\shell\open\command]
@="\"%1\" %*"

If you would rather do it by hand, open Registry Editor and set each Default value in the table above, then restart. There is one catch: when the .exe association is broken, regedit.exe and cmd.exe may refuse to open by double-click too. Get around it with Task Manager, which launches programs directly instead of through the broken association. Press Ctrl+Shift+Esc, choose Run new task, type regedit (or cmd), tick “Create this task with administrative privileges,” and press Enter.

Command Prompt has a one-line option as well. Microsoft’s assoc command restores the extension mapping:

assoc .exe=exefile

Two things to know. assoc is a Command Prompt built-in and is not available in PowerShell or Windows Terminal’s default profile, so run it in cmd, or use cmd /c assoc .exe=exefile. And it only repairs the .exe-to-exefile link; if the open\command value was changed too, you still need the registry fix above to set it back to "%1" %*. Changing associations requires administrator rights either way.

Boot to Safe Mode if the fix won’t stick

If you repair the association and it breaks again within minutes, malware is almost certainly re-applying it while Windows runs. Safe Mode starts Windows with a minimal set of drivers and services, which usually stops that software from loading so your fix can hold.

Per Microsoft Support, go to Settings > System > Recovery and select Restart now under Advanced startup. After the reboot, choose Troubleshoot > Advanced options > Startup Settings > Restart. On the list that appears, press 4 for Safe Mode or 5 for Safe Mode with Networking. Apply the registry fix there, then restart normally.

Scan for malware, then verify

Because file-type hijacking is a common malware behavior, treat this as a possible infection even if the association now works. Run a deep scan with the built-in tool. Microsoft’s Defender Offline scan is the one to use here: open Windows Security > Virus & threat protection > Scan options, pick Microsoft Defender Offline scan, and let the PC restart to check for threats before Windows fully loads. Save your work first.

If malware turns out to have removed or encrypted anything, our guide to recover deleted files on Windows walks through the options. And if the machine feels sluggish afterward, hidden background processes are a frequent cause, covered in why your Windows PC is so slow.

Once .exe files open normally and a scan comes back clean, you are done. This problem is not tied to one Windows version; the same registry values apply on Windows 7, 8.1, 10, and 11, though if you are still on Windows 10 it is worth reading what to do about Windows 10 end of support while you have the hood open.

Discussion

    Leave a comment