A simple windows default notepad replacement script: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(minor updates)
m (Reverted edits by 199.48.147.37 to last version by Kichik)
 
Line 68: Line 68:
SectionEnd
SectionEnd
</highlight-nsis>
</highlight-nsis>
== Your Life Is What You Make It ==
If you limit your choices only to what seems possible or reasonable, you disconnect yourself from what you truly want, and all that is left is compromise. Robert Fritz
[[http://goodvillenews.com/Your-Life-Is-What-You-Make-It-aTRqC9.html Your Life Is What You Make It]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
== Research Reveals Largest Ancient Dam Built by Maya Civilization ==
Recent excavations, sediment coring and mapping by a multi-university team led by the University of Cincinnati at the pre-Columbian city of Tikal, a paramount urban center of the ancient Maya, have identified new landscaping and engineering feats, including the largest ancient dam built by the Maya of Central America.
[[http://goodvillenews.com/Research-Reveals-Largest-Ancient-Dam-Built-by-Maya-Civilizat-cff.html Research Reveals Largest Ancient Dam Built by Maya Civilization]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
== 5 Principles for Inner Transformation at Work ==
People go to work to sustain themselves and produce value in the world. Yet work environments can also be stressful, filled with challenging responsibilities and personalities, and feel misaligned with our most deeply cherished values. Instead of sustaining us, the workplace can sometimes feel simply draining, and at worst, unwholesome for both ourselves and the world.
[[http://goodvillenews.com/5-Principles-for-Inner-Transformation-at-Work-TTklKV.html 5 Principles for Inner Transformation at Work]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
== 5 Great Lessons You Can Learn From Life ==
Life isnt meant to be easy, its meant to be lived..sometimes happy, other times rough. But with every up and down you learn lessons that make you strong.Can you step back from your own mind for a little while and realize that life is not as bad as you think it is?
[[http://goodvillenews.com/5-Great-Lessons-You-Can-Learn-From-Life-M0nUGD.html 5 Great Lessons You Can Learn From Life]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
== The Way of the Peaceful Parent ==
The Way is only learned by walking it. Here are the steps I recommend:* Greet your child each morning with a smile, a hug, a loving Good Morning! This is how we would all like to be greeted each day.
[[http://goodvillenews.com/The-Way-of-the-Peaceful-Parent-sdV8KN.html The Way of the Peaceful Parent]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]

Latest revision as of 17:22, 15 August 2012

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

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}"
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

This next section spawns an Internet Explorer window with a tiny bit of instructions in it, for useability's sake.

GetTempFileName $R0
  FileOpen $0 $R0 "w"
  FileWrite $0 "<html><body><h1>Thank you for installing Software, If you have any questions, please contact me in whatever way you see fit.</h1></body></html>"
  FileClose $0
  ExecWait '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$R0"'
  Delete /REBOOTOK $R0
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