You are here

how to run another instance of notepad++?

7 posts / 0 new
Last post
zelda9
Offline
Last seen: 2 years 1 month ago
Joined: 2022-06-16 14:11
how to run another instance of notepad++?

hi
i have installed notepad++ portable on my portable SSD where i maintain my 2nd workspace. however when i run notepad++ portable from my SSD i get error that " Another instance of notepad++ instance is running. Close other instances before running notepad++ portable". ya i have notepad++ running on my laptop which i do not want to close. because i have a lot of work going on in it. while i want to run separate instance of notepad++ from my SSD where i have 2nd workspace and i do different kind of works there. so any idea how to solve this problem. or portable apps devs can you guys please make changes to it and allow two independent instances of notepad++ be running one from my system and one from my portable SSD it same time.

i have report that issue on GitHub but no real help from them : https://github.com/notepad-plus-plus/notepad-plus-plus/issues/11793

thanks

John T. Haller
John T. Haller's picture
Offline
Last seen: 7 hours 33 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Registry

The base Notepad++ writes to the registry even when run in its built in portable mode. So our portable launcher needs to backup and restore that. Two instances are unsupported as a result.

As a workaround, you could open the Notepad++Portable.ini within Notepad++Portable\App\AppInfo\Launcher and rename the 3 notepad++.exe entries in the first section to something else and then rename the appropriate EXEs within Notepad++Portable\App\Notepad++ and Notepad++Portable\App\Notepad++64 to match. Note that this may or may not work, will need to be redone after each upgrade, and is completely unsupported.

Sometimes, the impossible can become possible, if you're awesome!

zelda9
Offline
Last seen: 2 years 1 month ago
Joined: 2022-06-16 14:11
The base Notepad++ writes to

The base Notepad++ writes to the registry even when run in its built in portable mode. So our portable launcher needs to backup and restore that. Two instances are unsupported as a result.

so how about using different registry location maybe create registry with notepad++portable name ??

Ken Herbert
Ken Herbert's picture
Offline
Last seen: 2 hours 42 min ago
DeveloperModerator
Joined: 2010-05-25 18:19
That would require changes to

That would require changes to Notepad++ itself. We only make the programs portable, we don't change the base apps to make them portable.

ChocOrange
Offline
Last seen: 8 months 2 weeks ago
Joined: 2018-03-15 17:28
How to create 2nd instance

If you Open Notepad++ and then drag a tab out of the main window, Notepad++ will create a 2nd instance.

Not tested if it causes issues with leaving registry entries.
It will keep the tabs of the last closed instance.

artie-finkelstein
Offline
Last seen: 8 months 1 week ago
Joined: 2023-11-15 12:32
PA vs system Npp

I solve the 'instance is already running' problem with a batch file I've written and installed as a 'parallel' portable app. This batch file starts the PA version if Npp is not running, otherwise it uses the currently active process. Note: all instances of " MUST be replaced with the regular ASCII double quote character, all instances of ' can be replaced with the regular ASCII single quote character.

@echo off
:: Npp{mas}.bat -- version 1.01b (2023.11.15^)

:: if Notepad++ is not running, start the PortableApp version
::  else use whatever version is running

:: =======================================================================

:: Note:    this code is not licensed, warranted, guaranteed or supported for any application or use

:: =======================================================================
:: limitations:
::  does NOT block launching a local Notepad++ session using the '-multiInst -nosession' flags
::    nor is it fully/properly tested with all combinations of these flags
::  developed on a Win7 Pro (x64) system
::  only tested briefly on a Win8.1 (x32) system
::  assumes 'Command Extensions' are enabled

:: =======================================================================
:: assumes this 'app' is located next (parallel) to the standard Notepad++ folder in the PortableApp directory:
:: notes:
::  the '-mas' suffix is my default for non-standard PortableApp program 'installations'
::  the '{mas *}' suffixes are used to separate this code from the PortableApp and/or Notepad++ code
::
:: D:\PortableApps\
:: |-- Notepad++-mas                    this 'app'
:: |   |-- App\
:: |   |   `-- AppInfo\
:: |   |       |-- appicon.ico          copied from the default Notepad++Portable folder
:: |   |       `-- appinfo.ini          copied from the default Notepad++Portable folder (see below)
:: |   `-- Npp{mas}.bat                 this file
:: |-- Notepad++Portable\               default PortableApp version of Notepad++
:: |   |--

:: the AppInfo file has minimal changes from the installed/default AppInfo file:
:: D:\PortableApps\Notepad++-mas\App\AppInfo\appinfo.ini
::  [Details]
::  Name=Notepad++ {mas launcher}       suffix differentiates this app from the default in the menu
::
::  [Control]
::  Start=Npp{mas}.bat                  arbitrary name, but must match this batch file name

:: =======================================================================
:: =======================================================================
:start

:: -----------------------------------------------------------------------
:checkIfRunning
:: determine if a Notepad++ session is active

:Tasklist
:: if Notepad++ is running, the Tasklist code shows:
::
::Image Name:   notepad++.exe
::PID:          ????
::Modules:      ntdll.dll
::              (other traceable DLLs)
::
::else Tasklist shows:
::INFO: No tasks are running which match the specified criteria.

::  usebackq                                protect the double quotes in the for loop argument
::  tokens=3                                1=Image  2=Name:  3=notepad++.exe  (will be assigned to %%A)
::  tasklist                                lists the running processes
::      /M                                  focus on modules
::      /FI "imagename eq notepad++.exe"    filter in  :: name must match 'notepad++.exe'
::      /FO list                            filter out :: list format (see results shown above)
::
:: note the 'inverse' logic used to detect the 'INFO: No tasks' message; the /FI flag has narrowed the search field
:: if Notepad++ is running, the 'if' compare fails and execution falls through to the ':useExisting' code
::
for /F "usebackq tokens=3" %%A in ( `tasklist /M /FI "imagename eq notepad++.exe" /FO list` ) do if /i not ["%%A"]==["notepad++.exe"] (

REM :cmdow
REM :: normally I use 'cmdow' for task detection and manipulation (a cleaner, more unix-like interface)
REM :: but using 'Tasklist' ensures other computers have all the required support files
REM :: cmdow - Ritchie Lawrence / Jason Hood
REM :: MIT License
REM :: https://github.com/adoxa/cmdow
REM :: /e checks for the process, returns ERRORLEVEL 0 if running
REM cmdow Notepad++* /e
REM if ERRORLEVEL 1 (

    rem the remaining/following code is common to both detection techniques
    if defined _VERBOSE echo starting Notepad++Portable
    start "Npp{mas}" "..\Notepad++Portable\Notepad++Portable.exe" %*
    exit /b 0  )


:: -----------------------------------------------------------------------
:useExisting
:: use the currently running version (may be the PortableApp version, may be the system installed version)
:: Note:  does not always force the window for the running task to the top of the desktop Z order
:: uses Powershell to get the full path of the running version
:: Note:  PowerShell will object if Notepad++ is not running, but the above :checkIfRunning code handled that case

:: https://superuser.com/a/984759
::  usebackq        protect the double quotes in the for loop argument
::                  the double quotes are needed to protect the ')' in the for loop argument
::  delims=         tell cmd to NOT use regular 'for' loop result parsing based on spaces or tabs
::
for /f "usebackq delims=" %%A in ( `PowerShell "(Get-Process Notepad++).Path"` ) do (
    if defined _VERBOSE echo using the existing Notepad++ process
    "%%~A" %*
    exit /b 0  )


:: -----------------------------------------------------------------------
:exit
:: failed to detect or (re)launch Notepad++ - set a non-zero ERRORLEVEL
exit /b 1
JLim
Offline
Last seen: 2 months 2 weeks ago
Joined: 2013-07-17 01:30
A more simple way is just add

A more simple way is just add an entry in the launcher ini.

[Launch]
SingleAppInstance=false

But do not complaint 2 set of data, local and portable, mix up.

Log in or register to post comments