Skip to content

Commit

Permalink
Trigger the install in new version notepad++
Browse files Browse the repository at this point in the history
Refinement the install bat
Prepare to release 2.3.3
  • Loading branch information
lygstate committed Apr 27, 2020
1 parent c23971a commit 6dfb1ac
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 57 deletions.
15 changes: 7 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
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

- if "%platform%"=="x64" set archi=amd64
- 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:
Expand Down Expand Up @@ -67,5 +66,5 @@ deploy:
force_update: true
on:
appveyor_repo_tag: true
PlatformToolset: v141_xp
PlatformToolset: v142
configuration: Release
13 changes: 11 additions & 2 deletions plugin/NotepadStarterPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions plugin/NotepadStarterPlugin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
12 changes: 7 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Running the script ${Notepad++InstallDir}\plugins\NotepadStarter\NotepadStarterUninstall.bat
4 changes: 2 additions & 2 deletions starter/NotepadStarter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ 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")
{
executableScript += L"NotepadStarterReplacer.bat";
}
else if (cmd == L":uninstall")
{
executableScript += L"NotepadStarterUninstall.bat";
executableScript += L"NotepadStarterUninstall.bat uninstall";
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions starter/NotepadStarter.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)utils;$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\$(ProjectName)-Int\</IntDir>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
56 changes: 37 additions & 19 deletions starter/NotepadStarterInstall.bat
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

Expand Down
12 changes: 4 additions & 8 deletions starter/NotepadStarterRelease.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%\
)

copy /y %1\%CONFIGURATION%\NotepadStarter.exe %ReleaseDir%\NotepadStarter\
copy /y %1\%CONFIGURATION%\NotepadStarterPlugin.dll %ReleaseDir%\
16 changes: 12 additions & 4 deletions starter/NotepadStarterUninstall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/VersionInfo.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6dfb1ac

Please sign in to comment.