Why are there two copies of Notepad?


You may have noticed that there's a copy of Notepad in %windir%\notepad.exe and another in %windir%\system32\notepad.exe. Why two?

Compatibility, of course.

Windows 3.0 put Notepad in the Windows directory. Windows NT put it in the System32 directory.

Notepad is perhaps the most commonly hardcoded program in Windows. many Setup programs use it to view the Readme file, and you can use your imagination to come up with other places where a program or batch file or printed instructions will hard-code the path to Notepad.

In order to be compatible with programs designed for Windows 95, there needs to be a copy of Notepad in the Windows directory. And in order to be compatible with programs designed for Windows NT, there also needs to be a copy in the System32 directory.

And now that Notepad exists in both places, new programs have a choice of Notepads, and since there is no clear winner, half of them will choose the one in the Windows directory and half will choose the one in the System32 directory, thereby ensuring the continued existence of two copies of Notepad for years to come.

Comments (85)
  1. Anonymous says:

    Hmmmm…..on NTFS are they both hard links to the same file?

    (More importantly, how could I get explorer to tell you this? What’s the windows equivalent of ls -i?)

  2. Anonymous says:

    The WINDOWS directory tree has always seemed like a mishmash.  Maybe there’s some level of organization that’s just not obvious.

    It has never been clear to me what the distinction is between WINDOWSsystem and WINDOWSsystem32.  Is the former really just for 16-bit stuff?  Do we get a WINDOWSsystem64 on 64-bit machines?

  3. Anonymous says:

    I’d say the stupid part here was the decision to put notepad in different places in win3.0 and winNT.

  4. Anonymous says:

    Isn’t notepad.exe almost always in the path?

    It would be pretty odd to see a program say "I can’t display the readme because I can’t find notepad" though.

  5. Anonymous says:

    A related issue is what influences if a program goes in the Win/Sys32 directory or in the Program Files directory. Notepad is apparently part of the core Windows system and goes in Win/Sys32. WordPad, however, is a program and goes under Program Files. Ms Hearts is part of the system and goes under System32. Pinball, however, is a program, and goes under Program Files. Honestly I don’t see why there are over 20 subdirectories in Program Files after a fresh install of Windows XP. I haven’t installed any programs yet – just Windows!

  6. Anonymous says:

    In earlier windows System could sit on a server with windows local. Anything in windows would override what was in system. Then 95 reversed it.

  7. Anonymous says:

    "Do we get a WINDOWSsystem64 on 64-bit machines?"

    No, the 64-bit stuff goes in system32 and the 32-bit stuff goes in a different place that gets redirected to system32 for 32-bit processes.

    "Isn’t notepad.exe almost always in the path?"

    Or associated with .txt files.  And if notepad isn’t associated with .txt files, it might be more appropriate to use whatever application is.

  8. Anonymous says:

    What exactly is the reason to have (on x64) System32 for 64bit dlls and a different path for 32bit ones. Wouldn’t it be easier to have System32 for 32bit ones and System64 as the 64bit one ?

  9. Anonymous says:

    Brian,

    Programs specified a path to notepad and so the %path% isn’t searched.

  10. Anonymous says:

    I think its backwards compatibility again. Though you would think anyone taking the trouble to recompile their app for 64bit would also take the time to remove any hardcoded references to system32.

    Perhaps it’s for compatibility with scripts, which are run under a 64bit interpreter.

  11. Anonymous says:

    Some programmers that paths must be hardcoded for security, and that picking random programs that happen to have the same name up from the path is unsafe. They feel that running the application associated with .txt may be more likely to trigger malware than just starting the exe, especially when they "know" where the exe is.

    Thankfully, very very few programs use this, I’ve not seen this behaviour for years. I use the third party EditPad, and installers will either open readmes in this, or in their own dedicated textarea. Because, if you’re gonna jerk around with fixed paths for "security", you might as well Do It Right and just display the file yourself.

  12. Anonymous says:

    I hope that one day we will have full explanation of all these directories under the Windows directory eg. Addins, etc, and what they are for. The same goes for all these registry entries. Why isn’t Windows operating system properly documented?

  13. Mike Dunn says:

    The system dir for 64-bit apps is called system32. The system dir for 32-bit apps is called something funny like system32wow64. But a 32-bit app will still see it as "system32" due to some magic the OS does, all in the name of (wait for it) backcompat.

  14. Jack Mathews says:

    Nektar:

    Plenty of registry entries are documented on MSDN.  The ones that aren’t are ones that may be moved somewhere else and are accessible by API calls.

  15. Anonymous says:

    Yeah but compatibility with Windows 1.01, when Notepad was in windowsbin (IIRC) is still broken  :-)

  16. Anonymous says:

    Why did you make this hacks? Why didn’t windows have symbolic links?  

  17. Anonymous says:

    If this was about programs specifying the path to Notepad.exe then Windows should refuse to install to any other directory than C:Windows for the same reasons. That is apparently not the case so the argument about not breaking apps with hardcoded paths is bogus. What is the real reason?

  18. Anonymous says:

    Is it really two copies of notepad or is it like the write.exe that just does a exec or createprocess on wordpad. If its two copies of the same app that is really dumb.

  19. Anonymous says:

    Leandro, not all Windows file systems support links.

  20. Anonymous says:

    There are more than two copies. There is also one in the WFP folder.

  21. Anonymous says:

    I suspect that the distinction between apps in Program Files and apps in WindowsSystem32 is a historical one more than anything else. The apps you find in Program Files are ones that were added with Win95 or with a later version. Notice that there are some little back-compat stubs in the Windows directory for write.exe and pbrush.exe.

  22. Anonymous says:

    Raymond, I like your blog a lot and read it daily, but I have to point out that it makes people like me feel how braindead some part of Windows is, despite the fact that you are always coming from the angle how it’s not Windows’ fault.

    This one is a perfect example. It’s a messed up system, yet you sound like we should give credit to Windows how hard it has tried to accomodate it.

  23. Anonymous says:

    "the 64-bit stuff goes in system32 and the 32-bit stuff goes in a different place that gets redirected to system32 for 32-bit processes. "

    PRICELESS, the first problem was the naming of 32 in the first place LOL.

    Oh dear god, this is priceless engineering, you lot have Apple running for cover now :D

    Its bad practice to use app32.exe or someFolder32 that right there is walking into problems.

    NO wonder people are dumping windows for Macs.

  24. Anonymous says:

    File associations, the association for the filetype should have the path to the application that handles the opening, editing etc

  25. HAHAHAHA,

    Yeah, when I told my mother about the System32 64 bit magic she busted out laughing and immediately headed off to the store to get a Mac.

    In reality, where I live, the average person doesn’t know or care about that stuff. They care much more about whether or not the app they’ve been using for 8 years runs without a bunch of tweaking on their new PC when it comes with it’s new version of the OS. If Microsoft could depend on all of the crappy devs out there to  update their apps (even after they are out of business) then all this app compat junk would be unnecessary. Since we live in a real world with a huge number of developers of dubious skill we have to make sacrifices to accommodate that. Grow up…

  26. microbe: It was a bad decision made in 1989. Until time travel has been perfected, we just have to accept our mistakes and cope as best we can.

  27. Anonymous says:

    But 2 important questions remain:

    1) Is notepad.exe actually stored twice on disk, or is the Windows installation clever enough to create a link? (this is ofcourse difficult when installing on fat32, so a stub like Steven said would even better)

    2) Why did NT put notepad.exe in a different directory in the first place? Wasn’t there a BC problem with it back then?

  28. Anonymous says:

    It’s 2 copies of the 68KB executable.

  29. Anonymous says:

    "No, the 64-bit stuff goes in system32 and the 32-bit stuff goes in a different place that gets redirected to system32 for 32-bit processes."

    Whoa, whoa, WHOA!

    So, if I have a 64-bit explorer-type program and a 32-bit explorer-type program (or, say, am browsing my filesystem with 64-bit IE7 and 32-bit Firefox) and have a look at %windir%system32 in each, I’ll see different files?

    wtf?!?

    I can see the family tech support calls now:

    Parent: Gromit 1.5 isn’t working. 1.4 did.

    Me: Go to the system32 directory, find blargle.dll, right-click, select properties, tell me what version number it is.

    Parent: blargle.dll isn’t there.

    Me: Are you looking in that directory with a 32-bit explorer or 64-bit explorer.

    Parent: wtf? how in the name of badgers should I know?!? And why on earth does it matter?

    Ray – this isn’t true is it? Please tell me this guy is on crack or something!

  30. Adam,

    It’s not quite that convoluted. The user can see all three directories, System, System32 and SysWOW64 from both 32 bit and 64 bit programs (or at least I can). I testedusing botht he 32bit and 64bit versions of notepad.

    I believe the magic happens in the installer, seehttp://blogs.msdn.com/heaths/archive/2005/10/24/484266.aspx

  31. Anonymous says:

    There is precedent for a stub.  When Windows Write was removed in favor of Wordpad they couldn’t just get rid of write.exe because a lot of dumb apps did the same thing of trying to run it from a hardcoded directory.  So there is a now a write.exe that does nothing except turn around and run wordpad.exe.

  32. Anonymous says:

    For those suggesting hard links it’s probably not a good idea since very few Windows users know hard links even exist. Installing them with the OS will probably cause a lot of confusion or anger that Microsoft is using some "undocumented" file system feature.

  33. Anonymous says:

    Jerry Pisk wrote: "If this was about programs specifying the path to Notepad.exe then Windows should refuse to install to any other directory than C:Windows for the same reasons. That is apparently not the case so the argument about not breaking apps with hardcoded paths is bogus. What is the real reason?"

    The path doesn’t have to be hard-coded.  Suppose the programmer called GetSystemDirectory but notepad lived in the windows directory.  Or vice versa.

  34. Anonymous says:

    As Brian mentioned, a smart app shouldn’t have to worry too much about *where* notepad is. The default path on Windows 2000 and XP has %SystemRoot%system32 and then %SystemRoot%, so it would pick one of the notepads.

    Another option would be to run "start yourtextfile.txt", which will launch the text file in the application handler for .txt files.

  35. steveg says:

    microbe: what would you have done? Dunno about you, but I think it would be tremendously difficult to design an operating system while contemplating what might happen in the next decade — who would’ve thought Alpha, PowerPC and Itanium would be (from a PC point-of-view) dead. The fact Windows + OS/X are binary-backwards compatible (somewhat to mostly) continually amazes me. I still play the silly little games that came with some windows 3.1 games pack.

    As for symlinks/junctions, they’re cool for techies, but they do verge close to the "too-hard" basket for a lot of people. However, I do think Windows could’ve done a better job with its Shortcuts, and somehow merged their metadata into a NTFS level junction (FAT compatibility was obviously the issue in Win95).

    I do wish Explorer would display junctions differently. Maybe Vista does?

  36. Anonymous says:

    Not Entirely on topic, but I wish there was easier way to replace Notepad with Something Useful than to mess around with all the copies of it hanging around. There should be some UI to specify what to replace notepad with, without messing around with file "protections" and the multiple copies.

  37. Anonymous says:

    In Windows 95, notepad.exe wasn’t even part of system startup, but some other programs were invoked config.sys or autoexec.bat.  One of those programs that was executed during system startup was located in different directories in different versions of Windows 95.  However, in any given version of Windows 95, there was only a single copy of that program in one directory.  Why weren’t there two copies?

    Sorry it’s been a while and I don’t remember the crucial details.  Probably "nls" was part of the filename but it might have been something else named in the same area of config.sys or autoexec.bat.  One of the directories was the Windows directory and the other was probably either WindowsCommand or WindowsSystem.

    The program was definitely accessed by a fully hard-coded pathname, none of those creampuff soft "GetSystemDirectory" or %WINDIR% hacks.

  38. Edge says:

    As with the others, I’d think a hard link would rectify this situation rather than duplicating the file twice. Though I do seem to recall apps installing their own notepad.exe over the one provided by Microsoft (it’s been a *long* time since I’ve ran Windows 3.1 so don’t expect me to remember details, heh). Maybe that’s the reason for keeping them separated.

  39. Anonymous says:

    "So, if I have a 64-bit explorer-type program and a 32-bit explorer-type program and have a look at %windir%system32 in each, I’ll see different files?"

    Well it happens that there are 2 versions of Explorer, one 64-bit and one 32-bit.  And yes, you see different files in system32 from each.

    Given the fact that redirection exists, it HAS to work this way in order for 32-bit explorer extensions to work.  They need access to system32 to load extra dlls and to manipulate files.

  40. Anonymous says:

    Notepad can also be installed on the computer, even it’s there already, by just installing it from a custom setup package. Since you can control the location of an install, more than 2 copies of Notepad can also co-exist on a system :) on many different locations.

    Good blog you got going here. Blog on and keep bringing History Alive! If you like computer problem cartoons do visit http://spaces.msn.com/sillygloop when you find time.

  41. Anonymous says:

    HAHAHA says, "NO wonder people are dumping windows for Macs."

    It’s an interesting idea for an alternate history story.

    In this timeline, however, "Apple’s share of the worldwide PC market has tumbled from 4.6 percent in 1996, the year before Jobs returned, to just 2.2 percent in 2005."  Or so says the San Jose Mercury News, Apple’s hometown paper.

    Which means one of two things: Either people have actually been dumping Macs for Windows — possibly because the kind of vocal "evangelism" for Macs from devotees like HAHAHA turns people off (Linux suffers from this problem, too) — or the Mac platform has been growing, but much more slowly than Windows.

    http://www.mercurynews.com/mld/mercurynews/news/breaking_news/14187018.htm

  42. Anonymous says:

    one word:symlink (look it up windows douchebags)

  43. Anonymous says:

    Just looking at an XP system, most default associations use %SystemRoot%system32NOTEPAD.EXE but "scriptletfile" uses C:WINDOWSNOTEPAD.EXE – not one, but two mistakes! No wonder Disk Management won’t let you fiddle with the drive letter of your system drive (although I could never figure why your boot drive was similarly restricted).

    Setup routines that still want to launch on 9x will choose to execute C:WINDOWSNOTEPAD.EXE, so there’ll still be a little bit of bias.

  44. Anonymous says:

    The funny thing is that changing the drive letter of your system drive appears to have got worse, rather than better, over time. NT 3.51 used %SystemRoot% everywhere and took a change in system drive letter in its stride; then NT4 started sticking the actual drive letter in (eg) HKCUAppEventsSchemes.

  45. Microbe,

    Welcome to Windows:)

  46. the man: Good luck getting symbolic links working on a FAT drive.

  47. Anonymous says:

    It’s kind of funny, but many unix systems deal with this by defining an EDIT variable, if I recall, to the filepath of the editor that user prefers to use.

    Unfortunately, for whatever reason, this environment variable is typically undefined in a Windows environment, and Windows provides no API for acquiring the filepath to the user’s preferred text editor.

  48. BryanK says:

    Trey Van Riper:  Most programs look at $VISUAL first (the user’s preferred "full-screen" editor), then $EDITOR as a fallback, and "vi" as a final fallback (because every *nix system has vi somewhere).

    Similar with $PAGER, the user’s preferred paging program (usually set to either "more" or "less") and $BROWSER, the user’s preferred web browser.  (Well, $BROWSER doesn’t have quite the same level of support yet.)

  49. Rup says:

    You could make one copy of notepad check if the calling program was using a debug system runtime and pop-up a warning "this copy is deprecated, please use the copy in system32".

  50. Anonymous says:

    Imagine taking the same analogy with Linux. Why do some developers stick applications in /opt, others in /var, others in /usr/share/local, and others in /usr/share, then hard or symbolically link them in /usr/bin (for most users), and /usr/sbin (for sysops), and /bin (for most users), and /sbin (for sysops)? And why are fonts sprayed all over the hard drive in a few different directories?

  51. Anonymous says:

    Imagine taking the same analogy with Linux. Why do some developers stick applications in /opt, others in /var, others in /usr/share/local, and others in /usr/share, then hard or symbolically link them in /usr/bin (for most users), and /usr/sbin (for sysops), and /bin (for most users), and /sbin (for sysops)? And why are fonts sprayed all over the hard drive in a few different directories?

  52. Anonymous says:

    supermike: The division between directories is specified in the FHS – http://www.pathname.com/fhs/ – and there are good reasons behind it.  Some developers don’t follow the standard, but that’s hardly surprising.  For the most part, programs are found by searching the path.

  53. vince says:

    Oldnewthing:  Good luck getting

    > symbolic links working on a FAT

    > drive.

    You should research something called "UMSDOS" that was a filesytem on Linux.  It allowed long filenames, device files, and symbolic links on top of a plain (and valid) FAT filesystem.  This predated VFAT.

    Just because something is hard doesn’t mean it is impossible…

  54. Anonymous says:

    Vince: UMSDOS was fairly cludgy, easier to lose information with than say LFNs in VFAT.

    Still; yes it is possible… probably not desirable, the stub way would probably be the windowsy way to do it.

  55. Anonymous says:

    So when I go Win-R and go notepad [enter], which Notepad am I using?

  56. Anonymous says:

    Gents and Ladies,

    We have officially uncovered the root of the problem behind the Vista delay.

  57. Anonymous says:

    Compability talk?

    Maybe consider IE 6.0, which isn’t compatible with CSS 2.1, which was released 1999, am i right?

    Same thing with XHTML ;)

    How sad…

    they probably want to be compatible only with their own products ;)

  58. Anonymous says:

    They’re in:

    <ul>

    <li>%windir% (c:windows)</li>

    <li>%windir%system32 (c:windowssystem32</li>

    <li>%windir%system32dllcache (c:windowssystem32dllcache</li>

    </ul>

    You remove any and they fill back in.  If you’re quick, you can replace them all.

  59. Anonymous says:

    It’s time for Windows to just start over.  To hell with backwards compatibility.

  60. Anonymous says:

    re: It’s time for Windows to just start over.  To hell with backwards compatibility.

    the people have started over, they call it linux

  61. Anonymous says:

    Don’t know.

    But with Unix variant O/Ses, something called ‘symbolic link’ would address this.

    The symbolic link just points from the linked location to the ‘real’ physical path location.

    Thus if you want to relocate a file, you can set a symlink to that an app will find it if it’s not in the ‘standard’ location.

    This is common practice.

  62. Anonymous says:

    Tony:  when you go, start, run, notepad.exe, you get the first one windows comes to when it searches the path.

    Trey Van Riper:  Regarding ‘default apps’, you can make a point that the way windows does it is very intuitive.  File extension associations are useful that way.

    NT put it in a different directory from Win95 because it started over.  NT was not related to 9x.  It ignored the 640k RAM barrier.  It was 32bit only.  And very stable.

    Then came xp when the NT and 9x forks merged.

    I agree, MS should start over.

    —–

    Xal

    {Arguing the superiority of a given OS is silly, since it is all about opinions.}

  63. Anonymous says:

    Doesn’t seem to work for me…

    $ %windir%notepad.exe

    -su: fg: %windir%notepad.exe: no such job

  64. Anonymous says:

    Nektar wrote:

    > I hope that one day we will have full

    > explanation of all these directories under

    > the Windows directory eg. Addins, etc, and

    > what they are for. The same goes for all

    > these registry entries. Why isn’t Windows

    > operating system properly documented?

    It’s ironic that this comment was made on this particular article.  So many of Raymond’s posts, this one included, explain seemingly weird behavior or decisions in Windows that exist purely to preseve compatibility with applications that made some assumptions that certain things in Windows would never change.  In this case, the assumption is the location of notepad.exe.

    If the Windows team documented registry keys it uses internally, people would take dependencies on them, and they would never be able to be changed.  It’s bad enough already even though much of it is NOT documented…people just troll through the registry anyway and say, "hey, this looks like a setting I can twiddle with".

    And then later, if the setting is preserved forever, people say "why doesn’t Microsoft ditch that crappy backwards compatibility".  If the setting is changed, others complain "hey, Microsoft broke my application!  Let’s sue them!", even though the application was relying on undocumented behavior to begin with.

    So define "properly documented".  In software, the documentation for an interface should NOT include details about how it is implemented.  Not only should it not be necessary for you to know, but you shouldn’t WANT to know, because you may inadvertently become dependent on the implementation instead of the interface, and implementations can change.  The same thing applies to dealing with the OS, or any other development platform.

  65. Anonymous says:

    that’s happens when there is no delay for releases!

    let’s hope that vista comes just with one notepad!

    :)

  66. Anonymous says:

    Josh>

    *boggle*

  67. Anonymous says:

    We’re talking about a modern OS here, nobody should be using a FAT drive.

  68. Anonymous says:

    Hardlinks and symlinks aren’t used very extensively in most current Windows systems, and many users would not expect them and apps would not handle them properly.  Are you suggesting that the 68KB you would save by only having one copy of notepad.exe is really worth that much?

    Has the existence of two notepad.exe’s actually ever caused you a problem?  It’s a small burden for Microsoft, but surely not for most (if any) users.

  69. Tell that to the people who ran NT4 on FAT drives. Once you make a decision you have to stick with it for compatibility, and back in 1996, FAT was still very popular.

  70. vince says:

     Tell that to the people who ran NT4

    >  on FAT drives. Once you make a

    >  decision you have to stick with it

    > for compatibility, and back in 1996,

    > FAT was still very popular.

    In the old days I ran various Linux systems with FAT as the primary filesystem via the aforementioned UMSDOS.  Long filenames, permissions, and symbolic links were all supported transparently on top of plain FAT.

    While it is good that MS watches out for backwards compatibility, things would be so much better if MS also thought about forward compatibilty.

  71. Anonymous says:

    Of course, my question is, if 32-bit apps on Windows x64 see a remapped drive *anyway*, why are the 64-bit DLLs in System32.  That’s just so horribly painfully ugly, it must drive the Windows programmers to tears.

    The only reason I can think of is a bunch of the internal Windows stuff is hardcoded and the decision was made not to fix that.  You don’t have to worry about backcompat with 3rd-party apps since they’ll be recompiled/tested with 64-bit.

    Well, too late now that it’s released, I guess…

  72. Dean Harding says:

    In the old days I ran various Linux systems with FAT as the primary

    > filesystem via the aforementioned UMSDOS.  Long filenames, permissions,

    > and symbolic links were all supported transparently on

    > top of plain FAT.

    Why on earth would they have gone to all the trouble of implementing something like UMSDOS just to save 68KB? Especially since FAT was only for backwards-compatibility as well.

    Maybe the "proper" solution would have been to use a hard-link on NTFS drives and a copy (or stub) on FAT drives, but it doesn’t matter now – that decision was made years ago and complaining now won’t change it.

  73. Anonymous says:

    We’re talking about a modern OS here, nobody should be using a FAT drive.

    FAT is used in many removable storage, as of now.

  74. Anonymous says:

    "In the old days I ran various Linux systems with FAT as the primary filesystem via the aforementioned UMSDOS."

    A good way to make Linux crawl, especially in the old days.

  75. Anonymous says:

    notepad.exe is so small that it is better to simply have two copies of the file.

    Nobody noticed that Write and Wordpad are two different programs with two different file names??? IT DOESN’T MATTER WHAT PATH THE APP WOULD SEARCH IT WOULD NEVER USE "wordpad.exe" INSTEAD OF "write.exe"!!!

  76. Anonymous says:

    I guess 2 notepads are better than one! j/k

  77. Anonymous says:

    Why does anyone hardcode the system32 part, and not the winnt/windows part?

    exe-files are programs, not system components.

  78. Anonymous says:

    dir c:windowsnotepad.exe /b

    NOTEPAD.EXE

    dir c:windowssystem32notepad.exe /b

    notepad.exe

    Why is there a difference in casing?

  79. Anonymous says:

    Mistakes were made.

  80. Anonymous says:

    Symlinks are one of most wished for Windows features.  Coming from the gnunix world, it’s easy for me to see how flexible you can make software deployment, integration, and security using them.  Anyone who’s ever been able to change their apache version simply by updating a symlink should be able to attest to this.  Yes, two notepads are not a big deal, but real symlinks would make Windows so much more fun use.

  81. Anonymous says:

    Hmm, there seems to be

Comments are closed.