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)
 
(2 intermediate revisions by 2 users not shown)
Line 68: Line 68:
SectionEnd
SectionEnd
</highlight-nsis>
</highlight-nsis>
== 15 Things You Should Give Up To Be Happy ==
Here is a list of 15 things which, if you give up on them, will make your life a lot easier and much, much happier. We hold on to so many things that cause us a great deal of pain, stress and suffering and instead of letting them all go, instead of allowing ourselves to be stress free and happy we cling on to them. Not anymore. Starting today we will give up on all those things that no longer serve us, and we will embrace change. Ready? Here we go:
[[http://goodvillenews.com/15-Things-You-Should-Give-Up-To-Be-Happy-r1EA1L.html 15 Things You Should Give Up To Be Happy]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
== Rats Walking Again After Spinal Cord Injury ==
Scientists in Switzerland have restored full movement to rats paralyzed by spinal cord injuries in a study that spurs hope that the techniques may hold promise for someday treating people with similar injuries.
[[http://goodvillenews.com/Rats-Walking-Again-After-Spinal-Cord-Injury-nBLFSB.html Rats Walking Again After Spinal Cord Injury]]
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
== Simple Ways Of Dealing With Conflict ==
Being in control of your life and having realistic expectations about your day-to-day challenges are the keys to stress management, which is perhaps the most important ingredient to living a happy, healthy and rewarding life.
[[http://goodvillenews.com/Simple-Ways-Of-Dealing-With-Conflict-n0JxBe.html Simple Ways Of Dealing With Conflict]]
[[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]]
== Googles Jolly Good Fellow on Inner Peace ==
Chade-Meng Tan (widely known as Meng) was among the earliest engineers to be hired at Google. When Google allowed engineers to spend 20% of their time pursuing their passion, Meng decided to spend his time on a cause dear to his heart: Launching a conspiracy to bring about world peace. Meng believes that world peace can be achieved -- but only if people cultivate the conditions for inner peace within themselves.
[[http://goodvillenews.com/Googles-Jolly-Good-Fellow-on-Inner-Peace-xfIvQS.html Googles Jolly Good Fellow on Inner Peace]]
[[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