A simple windows default notepad replacement script: Difference between revisions
Aranjedeath (talk | contribs) No edit summary |
(No difference)
|
Revision as of 17:37, 12 April 2008
| Author: Aranjedeath (talk, contrib) |
Usage
This script does the age-old replacement of the windows default notepad, with something else, in my particular case, I used notepad2. This example assumes only 2 things.
- That you are using windows xp though it should work on other versions
- That your notepad replacement is already named notepad.exe
Also, you can get the full (mine) version of the code, a finished version of the installer(that you can just use)(Feel free to test it on os's other than xp, I'm fairly sure it wont work on server2003) at My website If you dig around there, you'll find my email address (I'm the "webmaster" after all) and feel free to email me any new versions, or suggestions. Or just put them here.
The Code
Here, I've cut down the script to what you actually need plus a little bit.
!include "MUI2.nsh"
I recommend MUI2, but I don't believe that it will work on nsis compilers before version 2.34 or something. If it doesn't, you may have to use
!include "MUI.nsh"
for the user interface. However, in the interest of size, you could also omit it completely, as except for the uninstaller, the user never sees the window for long enough to care.
!define VERSION "1.0_Final" Name "Notepad2 Replacer Version ${VERSION}" Caption "Aranjedeath's Notepad2 Installer Version ${VERSION}" OutFile "Notepad2_Installer_${VERSION}.exe" CRCCheck force AutoCloseWindow true RequestExecutionLevel admin InstallDir $WINDIR\system32 !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES Section "" install SectionIn RO CreateDirectory $PROGRAMFILES\notepadbackup CopyFiles $INSTDIR\dllcache\notepad.exe $PROGRAMFILES\notepadbackup SetOutPath $INSTDIR\dllcache Delete $INSTDIR\dllcache\notepad.exe File "notepad.exe" File "notepad.ini" SetOutPath $INSTDIR Delete $INSTDIR\notepad.exe File "notepad.exe" File "notepad.ini"
As Notepad2 requires an .ini file to keep its settings, I figured it would be cleaner if the installer was the one that placed the file, and removed it, so that it would be more uniform.
WriteUninstaller $INSTDIR\uninstallnotepad2.exe SectionEnd UninstallText "This will Rollback the Notepad2 install. Please click uninstall to continue." Section "Uninstall" Delete $INSTDIR\notepad.exe CopyFiles $PROGRAMFILES\notepadbackup\notepad.exe $INSTDIR Delete $INSTDIR\dllcache\notepad.exe CopyFiles $PROGRAMFILES\notepadbackup\notepad.exe $INSTDIR\dllcache Delete $PROGRAMFILES\notepadbackup\notepad.exe Delete /REBOOTOK $INSTDIR\notepad.ini Delete /REBOOTOK $INSTDIR\dllcache\notepad.ini Delete $INSTDIR\uninstallnotepad2.exe RMDir /REBOOTOK "$PROGRAMFILES\notepadbackup" SectionEnd