Need command to restart Notepad ++
-
The TASKKILL command doesn’t really kill a process, instead it sends a signal to a process requesting to terminate itself.
not quite. with the
/f
switch intaskkill /f /im notepad++.exe
, the process will be terminated non graceful and immediately.
but your script is cool.you can put it directly into shortcut.xml, without an extra batch file:
<Command name="Restart" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /c taskkill /f /im notepad++.exe && "FULL_PATH_TO_YOUR\notepad++.exe"</Command>
-
@Meta-Chuh said:
with the
/f
switch intaskkill /f /im notepad++.exe
, the process will be terminated non graceful and immediately.You are right. I assumed that nobody wants to loose his unsaved documents, but there may be cases.
-
@Meta-Chuh
And how is such a combination of two code variants … does it violate the laws of criminal law?<Command name="Restart" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /c taskkill /f /im notepad++.exe && start notepad++.exe</Command>
-
You have to escape the
&
characters to be compliant with the XML syntax:<Command name="Restart" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /c taskkill /f /im notepad++.exe && start notepad++.exe</Command>
But why do you want to do that? It is not necessary to explicitly launch
cmd.exe
sincetaskkill
is a console command, hencecmd.exe
is started automatically. Or, to be exact,taskkill
is started and attached to a new console.EDIT: Forget what I wrote above, you want to start Npp after terminating the running instance, thus you need to call
cmd.exe
. -
@dinkumoil I just want to get the most minimal code.
-
Ah, now I understand your point, you erased the
FULL_PATH_TO_YOUR\
part of @Meta-Chuh 's code.Well, I would say you are lucky that it works without the full path to Npp. I guess currently Npp sets its own path as the current path when it executes the command. But I would not rely on that, maybe this behaviour changes in the future.
Over the years I got used to ALWAYS use fully qualified and quoted paths. This makes your scripts error proof and thus your life much more easy.
-
@dinkumoil I always use the portable version of Notepad ++, and try not to write full paths.
-
You can use the Npp environment variable
$(NPP_DIRECTORY)
. -
@dinkumoil said:
You can use the Npp environment variable
$(NPP_DIRECTORY)
.This is the most suitable way.
-
try
@echo off
taskkill /f /im notepad++.exe
“C:\Program Files\Notepad++\notepad++.exe”cls
-
@gurikbal-singh said:
try
@echo off
taskkill /f /im notepad++.exe
“C:\Program Files\Notepad++\notepad++.exe”cls
I tried to get rid of it … and you offer me to return to this?
-
I tried to get rid of it … and you offer me to return to this?
the translator of @gurikbal-singh is on holiday 😁
-
by the way:
And how is such a combination of two code variants … does it violate the laws of criminal law?
<Command name="Restart" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /c taskkill /f /im notepad++.exe && start notepad++.exe</Command>
lol, no, everything is legal 😉
your version is correct, mine was wrong, as it keeps the cmd window open.
i just have forgotten thestart
command while typing, sorry 🙏 -
Just for completeness, there is also the
$(NPP_FULL_FILE_PATH)
variable. -
@Ekopalypse said:
Just for completeness, there is also the
$(NPP_FULL_FILE_PATH)
variable.Please show me an example of your solution code.
-
I don’t have one, it was in response to your response about using $(NPP_DIRECTORY),
which would mean you need to concatenate directory and executable wheres $(NPP_FULL_FILE_PATH) is already the complete path.
Did I misunderstood something? -
@Ekopalypse I understood))