Skip to content

Commit

Permalink
Copy NotepadStarter.exe properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
lygstate committed Feb 7, 2018
1 parent bfe6ea8 commit 2011fe6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion PluginManager.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin name="NotepadStarterPlugin">
<unicodeVersion>2.1.0.0</unicodeVersion>
<unicodeVersion>2.3.0.0</unicodeVersion>
<description>This tool designed as a Notepad++ plugin by [Yonggang Luo](luoyonggang(at)gmail.com), when\nit installed as a Notepad++ plugin or running NotepadStarter.exe in the Notepad++ app\ndirectory, it's will automatically replace the system default notepad.exe application with\nNotepad++ (Without need for removing anything from the windows system.). It's tested\nunder Windows 7, but Windows XP should also works.</description>
<author>Yonggang Luo</author>
<homepage>https://github.com/lygstate/NotepadStarter/</homepage>
Expand Down
7 changes: 6 additions & 1 deletion plugin/NotepadStarterPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void TryInstallNotepadStarter() {
KEY_READ,
&hKey);
std::wstring NotepadPlusPlusExecutable = L"";
std::wstring NotepadPlusStarterExecutable = GetEnvironmentVariableValue(L"WinDir") + L"\\NotepadStarter.exe";
std::wstring NotepadPlusPlusSelf = GetThisExecutable();
std::wstring NotepadStarter;
bool hasNpp = false;
Expand All @@ -132,7 +133,11 @@ void TryInstallNotepadStarter() {
RegCloseKey(hKey);
}

if (!hasNpp || !ExistPath(NotepadPlusPlusExecutable) || NotepadPlusPlusSelf != NotepadPlusPlusExecutable) {
if (
!hasNpp ||
!ExistPath(NotepadPlusPlusExecutable) ||
!ExistPath(NotepadPlusStarterExecutable) ||
NotepadPlusPlusSelf != NotepadPlusPlusExecutable) {
#if 0
int ret = MessageBoxW(
NULL,
Expand Down
9 changes: 5 additions & 4 deletions starter/NotepadStarterInstall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ if not exist "%NotepadStarter%" ( goto NoNotepadPlusPlusOrNotepadStarter )
if not exist "%NotepadPlusPlus%" ( goto NoNotepadPlusPlusOrNotepadStarter )

::Gain Administrator permission
set SHOW_SUBWINDOW=0
set SHOW_SUBWINDOW=1
call "%~dps0request-admin.bat" "%~dpnxs0" %*

reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f
copy /Y %NotepadStarter% "%SystemRoot%\NotepadStarter.exe"
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f
del /F "%WinDir%\NotepadStarter.exe"
copy /Y "%NotepadStarter%" "%WinDir%\NotepadStarter.exe"
if defined UseImageFileExecution (
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Debugger" /t REG_SZ /d "%SystemRoot%\NotepadStarter.exe"
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Debugger" /t REG_SZ /d "%WinDir%\NotepadStarter.exe"
goto PreppareRegistry
)

Expand Down
2 changes: 1 addition & 1 deletion utils/VersionInfo.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define VERSIONINFO_INC

#define NS_VERSION_MAJOR 2
#define NS_VERSION_MINOR 0
#define NS_VERSION_MINOR 3
#define NS_VERSION_MAINTENANCE 0
#define NS_VERSION_REVISION 0

Expand Down

0 comments on commit 2011fe6

Please sign in to comment.