Replacing NotePad

Started by Demarco, December 10, 2010, 05:28:52 PM

Previous topic - Next topic

Demarco

With another editor I was using I had developed a batchfile that would replace Windows built-in Notepad with the other editor.  I modified this script to replace Windows Notepad with Hippoedit.

The results were not good  :(.

1) I don't know how windows passes it's arguments to Notepad, but there must not be any double quites, because if there were any spaces in the file-path or file-name Hippoedit would break them up into seperate files.
2) The registration information was lost.
3) Initially the program would not start because it could not find some of it's DLL's.

Here is my batch-file if anyones interested:

IMPORTANT NOTE!! :o

IF YOU RUN THIS IT WILL MESS UP YOUR COMPUTER!  NOTEPAD WILL NOT WORK PROPERLY! ???


@echo off
:restart
if not exist "C:\Program Files\HippoEDIT\HippoEDIT.exe" goto NoPad

:prompt
if not exist %WinDir%\System32\dllcache\HippoEDIT.exe.orig goto backup
set /p userinp=Current Notepad already backedup, Overwrite or Skip? (O,S):
::set userinp=%userinp:~0,1%
if "%userinp%"=="O" goto backup
if "%userinp%"=="o" goto backup
if "%userinp%"=="S" goto install
if "%userinp%"=="s" goto install
if "%userinp%"=="C" goto done
if "%userinp%"=="c" goto done
echo Invalid Choice
echo Answer with an 'O' or a 'S' (or 'C' to cancel)
goto prompt

:backup
echo Save current NotePad EXE's
copy /y %WinDir%\System32\dllcache\notepad.exe %WinDir%\System32\dllcache\notepad.exe.orig
copy /y %WinDir%\ServicePackFiles\i386\notepad.exe %WinDir%\ServicePackFiles\i386\notepad.exe.orig
copy /y %WinDir%\System32\notepad.exe %WinDir%\System32\notepad.exe.orig
copy /y %WinDir%\notepad.exe %WinDir%\notepad.exe.orig
:install
echo Install new NotePad
copy /y "C:\Program Files\HippoEDIT\HippoEDIT.exe" %WinDir%\System32\dllcache\Notepad.exe
copy /y "C:\Program Files\HippoEDIT\HippoEDIT.exe" %WinDir%\ServicePackFiles\i386\Notepad.exe
copy /y "C:\Program Files\HippoEDIT\HippoEDIT.exe" %WinDir%\System32\Notepad.exe
copy /y "C:\Program Files\HippoEDIT\HippoEDIT.exe" %WinDir%\Notepad.exe
echo.
echo.
echo Write down the locations after the REG_MULTI_SZ or REG_SZ in case the batch file does not work.  If it does not work, you will need to look in the locations from below to find other copies of notepad.exe that are possibly being used to restore the original notepad.exe
echo.
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup /v "Installation Sources"
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup /v ServicePackSourcePath
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup /v SourcePath
goto done

:NoPad
echo Install Notepad++ first
echo The install is named "npp.5.3.1.Installer.exe"
echo.
if not exist npp.5.3.1.Installer.exe goto done

set /p userinp=Run the program? (Y/N):
if "%userinp%"=="Y" goto runpgm
if "%userinp%"=="y" goto runpgm
goto done

:runpgm
npp.5.3.1.Installer.exe
goto restart

echo.

:done

alex

Hi Demarco,

you already have answer to your problems in your post - you just have not copied all required files.
HippoEDIT is not only one executable: you have also GUI Library (guilib(u).dll), Text Editor library (editlib(u).dll) Tools library (toolslib(u).dll) and Shell Extension (ShellReg.dll) which should be placed in same directory as executable. Also in some case this should be MFC libraries + manifest files. And also you need to copy license file (license.dat) - this reason you have problems with registration.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]