From 6dfb1ac3ea7515837ce5cd9e5c6c671e2cd1d4d2 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 28 Apr 2020 03:45:08 +0800 Subject: [PATCH] Trigger the install in new version notepad++ Refinement the install bat Prepare to release 2.3.3 --- appveyor.yml | 15 ++++---- plugin/NotepadStarterPlugin.cpp | 13 +++++-- plugin/NotepadStarterPlugin.vcxproj | 12 ++++--- readme.md | 12 ++++--- starter/NotepadStarter.cpp | 4 +-- starter/NotepadStarter.vcxproj | 12 ++++--- starter/NotepadStarterInstall.bat | 56 +++++++++++++++++++---------- starter/NotepadStarterRelease.bat | 12 +++---- starter/NotepadStarterUninstall.bat | 16 ++++++--- utils/VersionInfo.inc | 2 +- 10 files changed, 97 insertions(+), 57 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 81e305f..ba01efc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,21 +1,20 @@ version: 2.0.0.{build} -image: Visual Studio 2017 +image: Visual Studio 2019 environment: matrix: #- PlatformToolset: v140_xp - - PlatformToolset: v141_xp - -platform: - - Win32 - - x64 + - PlatformToolset: v142 configuration: - Release - Debug install: + - if "%platform%"=="x86" set archi=x86 + - if "%platform%"=="x86" set platform_input=Win32 + - if "%platform%"=="Win32" set archi=x86 - if "%platform%"=="Win32" set platform_input=Win32 @@ -23,7 +22,7 @@ install: - if "%platform%"=="x64" set platform_input=x64 - if "%PlatformToolset%"=="v140_xp" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %archi% - - if "%PlatformToolset%"=="v141_xp" call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %archi% + - if "%PlatformToolset%"=="v142" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %archi% build_script: @@ -67,5 +66,5 @@ deploy: force_update: true on: appveyor_repo_tag: true - PlatformToolset: v141_xp + PlatformToolset: v142 configuration: Release diff --git a/plugin/NotepadStarterPlugin.cpp b/plugin/NotepadStarterPlugin.cpp index a1be199..49e7aee 100644 --- a/plugin/NotepadStarterPlugin.cpp +++ b/plugin/NotepadStarterPlugin.cpp @@ -151,9 +151,18 @@ void TryInstallNotepadStarter() { int ret = IDYES; #endif std::wstring installScript = GetParentDir(NotepadPlusPlusSelf) + L"\\plugins\\NotepadStarter\\NotepadStarter.exe"; - if (!ExistPath(installScript) && hasNppDir && ExistPath(NotepadPlusPlusDir)) { - installScript = GetEnvironmentVariableValue(L"AppData") + L"\\notepad++\\plugins\\NotepadStarter\\NotepadStarter.exe"; + if (!ExistPath(installScript)) { + installScript = GetParentDir(NotepadPlusPlusSelf) + L"\\plugins\\NotepadStarterPlugin\\NotepadStarter\\NotepadStarter.exe"; } + if (hasNppDir && ExistPath(NotepadPlusPlusDir)) { + if (!ExistPath(installScript)) { + installScript = GetEnvironmentVariableValue(L"AppData") + L"\\notepad++\\plugins\\NotepadStarter\\NotepadStarter.exe"; + } + if (!ExistPath(installScript)) { + installScript = GetEnvironmentVariableValue(L"AppData") + L"\\notepad++\\plugins\\NotepadStarterPlugin\\NotepadStarter\\NotepadStarter.exe"; + } + } + switch (ret) { default: case IDCANCEL: diff --git a/plugin/NotepadStarterPlugin.vcxproj b/plugin/NotepadStarterPlugin.vcxproj index 30d3e28..dec854c 100644 --- a/plugin/NotepadStarterPlugin.vcxproj +++ b/plugin/NotepadStarterPlugin.vcxproj @@ -94,22 +94,26 @@ true $(SolutionDir)utils;$(IncludePath) - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ true $(SolutionDir)utils;$(IncludePath) + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ false $(SolutionDir)utils;$(IncludePath) - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ false $(SolutionDir)utils;$(IncludePath) + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ diff --git a/readme.md b/readme.md index 9155659..bb2fbcc 100644 --- a/readme.md +++ b/readme.md @@ -36,10 +36,12 @@ Comments, issues and contributions can be done at [Github|NotepadStarter](https: ## Installation Downloading the NotepadStarter-major.minor.maintenance.revision.zip from [NotepadStarter releases](https://github.com/lygstate/NotepadStarter/releases) -Extract the content into ${Notepad++InstallDir}\plugins\, running Notepad++, then it's will prompt a window how two installing the NotepadStarter. -There is two mode: - * `Yes`: Install NotepadStarter as `notepad.exe Image File Execution` - * `No`: Install NotepadStarter to replace the system notepad.exe completely(backup the original `notepad.exe` as `notepad.NotepadStarter.exe`) + +### For newest version of notepad++ +Create directory ${Notepad++InstallDir}\plugins\ +Extract the content of downloaded zip file into ${Notepad++InstallDir}\plugins\NotepadStarterPlugin, running Notepad++, then it's will prompt a window to installing the NotepadStarter. +### For old version of notepad++ +Extract the content of downloaded zip file into ${Notepad++InstallDir}\plugins, running Notepad++, then it's will prompt a window to installing the NotepadStarter. ## Uninstallation - Running the script ${Notepad++InstallDir}\plugins\NotepadStarter\NotepadStarterUninstall.bat \ No newline at end of file +Running the script ${Notepad++InstallDir}\plugins\NotepadStarter\NotepadStarterUninstall.bat diff --git a/starter/NotepadStarter.cpp b/starter/NotepadStarter.cpp index 1c23ffb..36c8c5b 100644 --- a/starter/NotepadStarter.cpp +++ b/starter/NotepadStarter.cpp @@ -400,7 +400,7 @@ int DoCommand(wstring cmd) { wstring executableScript = GetParentDir(GetThisExecutable()) + L"\\"; if (cmd == L":install-registry") { - executableScript += L"NotepadStarterInstall.bat"; + executableScript += L"NotepadStarterInstall.bat install"; } else if (cmd == L":install-replace") { @@ -408,7 +408,7 @@ int DoCommand(wstring cmd) { } else if (cmd == L":uninstall") { - executableScript += L"NotepadStarterUninstall.bat"; + executableScript += L"NotepadStarterUninstall.bat uninstall"; } else { diff --git a/starter/NotepadStarter.vcxproj b/starter/NotepadStarter.vcxproj index 8f99d38..61e0a28 100644 --- a/starter/NotepadStarter.vcxproj +++ b/starter/NotepadStarter.vcxproj @@ -73,22 +73,26 @@ true $(SolutionDir)utils;$(IncludePath) - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ true $(SolutionDir)utils;$(IncludePath) + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ false $(SolutionDir)utils;$(IncludePath) - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ false $(SolutionDir)utils;$(IncludePath) + $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\ + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ diff --git a/starter/NotepadStarterInstall.bat b/starter/NotepadStarterInstall.bat index 35bded3..3c38727 100644 --- a/starter/NotepadStarterInstall.bat +++ b/starter/NotepadStarterInstall.bat @@ -1,27 +1,34 @@ ::By using short path, to support place in Unicode Path @echo on echo Args:[%*] -if not "%1"=="ReplaceSystemNotepad" ( -set UseImageFileExecution="UseImageFileExecution" -) - -cd /d %~dps0..\.. -set "NotepadPlusPlus=%CD%\notepad++.exe" set "NotepadPlusPlusDir=" -for /f "tokens=2,*" %%a in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Notepad++ /ve 2^>NUL') do set "NotepadPlusPlusDir=%%b" -if exist "%NotepadPlusPlusDir%" goto find_notepad_dir +for /f "tokens=2,*" %%a in ('reg query HKLM\SOFTWARE\Notepad++ /ve 2^>NUL') do set "NotepadPlusPlusDir=%%b" +if exist "%NotepadPlusPlusDir%" goto found_notepad_dir + +for /f "tokens=2,*" %%a in ('reg query HKLM\SOFTWARE\Wow6432Node\Notepad++ /ve 2^>NUL') do set "NotepadPlusPlusDir=%%b" +if exist "%NotepadPlusPlusDir%" goto found_notepad_dir + +for /f "tokens=2,*" %%a in ('reg query HKLM\SOFTWARE\Notepad++ /ve /reg:64 2^>NUL') do set "NotepadPlusPlusDir=%%b" +if exist "%NotepadPlusPlusDir%" goto found_notepad_dir + +for /f "tokens=2,*" %%a in ('reg query HKLM\SOFTWARE\Notepad++ /ve /reg:32 2^>NUL') do set "NotepadPlusPlusDir=%%b" +if exist "%NotepadPlusPlusDir%" goto found_notepad_dir + +:found_notepad_dir -for /f "tokens=2,*" %%a in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Notepad++ /ve 2^>NUL') do set "NotepadPlusPlusDir=%%b" +cd /d %~dps0..\.. +set "NotepadPlusPlus=%CD%\notepad++.exe" +if exist "%NotepadPlusPlus%" goto found_notepad_exe + +cd /d %~dps0..\..\.. +set "NotepadPlusPlus=%CD%\notepad++.exe" +if exist "%NotepadPlusPlus%" goto found_notepad_exe -:find_notepad_dir +set "NotepadPlusPlus=%NotepadPlusPlusDir%\notepad++.exe" -if not exist "%NotepadPlusPlus%" ( - if exist "%NotepadPlusPlusDir%" ( - set "NotepadPlusPlus=%NotepadPlusPlusDir%\notepad++.exe" - ) -) +:found_notepad_exe cd /d %~dps0 set "NotepadStarter=%CD%\NotepadStarter.exe" @@ -33,21 +40,32 @@ set SHOW_SUBWINDOW=0 call "%~dps0request-admin.bat" "%~dpnxs0" %* reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f +reg delete "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f +reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /reg:64 +reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /reg:32 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 "%WinDir%\NotepadStarter.exe" - goto PreppareRegistry -) +goto PreppareRegistry call :ReplaceNotepad "%SystemRoot%" call :ReplaceNotepad "%SystemRoot%\System32" call :ReplaceNotepad "%SystemRoot%\SysWOW64" :PreppareRegistry +reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Debugger" /t REG_SZ /d "%WinDir%\NotepadStarter.exe" +reg add "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Debugger" /t REG_SZ /d "%WinDir%\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" /reg:64 +reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Debugger" /t REG_SZ /d "%WinDir%\NotepadStarter.exe" /reg:32 + reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Notepad++" /t REG_SZ /d "%NotepadPlusPlus%" +reg add "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Notepad++" /t REG_SZ /d "%NotepadPlusPlus%" +reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Notepad++" /t REG_SZ /d "%NotepadPlusPlus%" /reg:64 +reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "Notepad++" /t REG_SZ /d "%NotepadPlusPlus%" /reg:32 + reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /v "readme" /t REG_SZ /d "call NotepadStarter.exe instead of original notepad.exe! To disable this option just remove notepad.exe entry" +if "%1"=="install" goto :oef + :NoNotepadPlusPlusOrNotepadStarter pause diff --git a/starter/NotepadStarterRelease.bat b/starter/NotepadStarterRelease.bat index eacd757..81487e1 100644 --- a/starter/NotepadStarterRelease.bat +++ b/starter/NotepadStarterRelease.bat @@ -2,18 +2,14 @@ cd /d %~dps0\.. echo Release with: %1 %2 %CD% set "CONFIGURATION=%2" -rd /s /q bin set ReleaseDir=bin\%1\%2\plugins +rd /s /q %ReleaseDir% mkdir %ReleaseDir%\NotepadStarter copy /y starter\NotepadStarterInstall.bat %ReleaseDir%\NotepadStarter\ copy /y starter\NotepadStarterUninstall.bat %ReleaseDir%\NotepadStarter\ copy /y starter\NotepadStarterReplacer.bat %ReleaseDir%\NotepadStarter\ copy /y starter\request-admin.bat %ReleaseDir%\NotepadStarter\ copy /y readme.md %ReleaseDir%\NotepadStarter\ -if "%1" == "x86" ( - copy /y %CONFIGURATION%\NotepadStarter.exe %ReleaseDir%\NotepadStarter\ - copy /y %CONFIGURATION%\NotepadStarterPlugin.dll %ReleaseDir%\ -) else ( - copy /y x64\%CONFIGURATION%\NotepadStarter.exe %ReleaseDir%\NotepadStarter\ - copy /y x64\%CONFIGURATION%\NotepadStarterPlugin.dll %ReleaseDir%\ -) \ No newline at end of file + +copy /y %1\%CONFIGURATION%\NotepadStarter.exe %ReleaseDir%\NotepadStarter\ +copy /y %1\%CONFIGURATION%\NotepadStarterPlugin.dll %ReleaseDir%\ diff --git a/starter/NotepadStarterUninstall.bat b/starter/NotepadStarterUninstall.bat index 8c8ab45..23afa0d 100644 --- a/starter/NotepadStarterUninstall.bat +++ b/starter/NotepadStarterUninstall.bat @@ -5,8 +5,6 @@ set SHOW_SUBWINDOW=0 call "%~dps0request-admin.bat" "%~dpnxs0" %* -reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f - call :RetrieveFileTime NotepadStarterTime "%SystemRoot%\NotepadStarter.exe" call :RecoverNotepad "%SystemRoot%" @@ -18,9 +16,19 @@ del /F /Q "%SystemRoot%\NotepadStarter.exe" cd /d %~dps0.. if exist "NotepadStarter\.git" (goto skipGitRepository) del /F /Q NotepadStarterPlugin.dll -rd /s /q NotepadStarter :skipGitRepository -::pause + +reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f +reg delete "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f +reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /reg:64 +reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /f /reg:32 + +if "%1"=="uninstall" goto uninstall_direct + +rd /s /q NotepadStarter & pause + +:uninstall_direct +rd /s /q NotepadStarter goto :eof :RecoverNotepad -Passing the directory have notepad.exe who will be replaced diff --git a/utils/VersionInfo.inc b/utils/VersionInfo.inc index fa0ee7a..06766c2 100644 --- a/utils/VersionInfo.inc +++ b/utils/VersionInfo.inc @@ -15,7 +15,7 @@ #define NS_VERSION_MAJOR 2 #define NS_VERSION_MINOR 3 -#define NS_VERSION_MAINTENANCE 2 +#define NS_VERSION_MAINTENANCE 3 #define NS_VERSION_REVISION 0 #define _NS_STR_HELPER(x) L#x