You are here: PSPad forum > Bug report / Hlášení chyb > Re: Issue when launching PsPad multiple times with relative program path
Posted by: X-Byte | Date: 2021-01-10 18:10 | IP: IP Logged
When already started, PsPad opens its own binary (PsPad.exe) for editing in a tab in addition to the actually desired text file.
This bug only occurs, when the setting:
Settings > Program Settings > System Integration > Only One Program Instanceis ENABLED
It does not occur, when multiple instances are allowed.
How to reproduce:
First launch PsPad with a relative path and and a text file as command line argument.
Then launch PsPad again with a relative path and and a text file as command line argument.
Example for CMD:
From pspad folder
Further analysis and probable cause
Total Commander forum thread
Quote:Dalai: My guess is that it compares its own path (C:\test\PsPad\PsPad.exe) to the path of the newly launched instance (C:\test\PsPad\Colors\..\PsPad.exe) - which obviously fails in such a case. But that's just a shot in the dark, and up to the developer to find out and solve
Posted by: pspad | Date: 2021-01-10 19:15 | IP: IP Logged
When PSpad is on the path with spaces in folders (e.g. program files folder), you need to put path into quotes
I tested it with current 5.0.4 version and there was no editing of the pspad.exe in hex editor.
I remember it occured in some old version, so I hoe you use current version.
Posted by: X-Byte | Date: 2021-01-10 20:09 | IP: IP Logged
Using the most recent 64 Bit version 5.0.4 (539) and confirmed the same issue with the same 32 Bit version. But this behavior has been there for many years. I know that you had a similar bug some years back and also remember the thread but I think this one is a different issue.
For testing purposes, PsPad.exe and all its files reside in C:\Test\PSPad so there's no space in its exe path nor the files it's supposed to open for editing. Even tried the aforementioned example commands with quotes around PSPad.exe's path, the issue persists. And the file for editing doesn't even have to exist yet.
I'm not the only one with this issue, as you can see in the linked Total Commander thread, where other users confirmed this.
As soon as there is some relative addressing in the path preceding PsPad.exe this issue occurs.
Even if you refer to the current path with the . reference the issue comes up and PSPad opens its own binary.
Please try to recreate the same setup and open a command box and try this with PSPad set to single instance:
Some interesting glitch: When omitting the ".exe" PSPad opens an empty tab labeled ".\PSPad", so somehow PSPad interprets its own execution command as first command line argument when set to "single instance" mode.
And as stated before, without any relative addressing components in the PSPad call, there's no issue. These work all flawless executed sequentially.
Edited 2 time(s). Last edit at 2021-01-10 20:14 by X-Byte.
Posted by: pspad | Date: 2021-01-10 20:31 | IP: IP Logged
First run is ok, cause there is standard application run with parameter. Second and another start is more complicated, because pspad needs detect that one instance is already running and send content of the command line to running instace.
Running instance must trim out pspad.exe and handle all possible parameters (see the help chapter related to command line) - multiple file names, switches,...
O kmow it looks easy from your point of view, but inside it is quite dificult.
E.g. when you select multiple files in windows explorer and use open in pspad, windows starts as many applications as the file count is (registry integration). You must let start only first instance abd all other instances must send files to this instance.
I tried your example but no pspad was open in hex editor and only files. I run it from TC command line, cause you point to TC forum.
Posted by: X-Byte | Date: 2021-01-10 22:50 | IP: IP Logged
I begin to understand it's not as easy as it might look from the outside, catching the right parameters from a newly started PSPad instance to hand over the files for opening in the existing instance.
I'm not complaining, in fact I love PSPad and it's my primary editor since more than ten years now (I think).
I was referring to the TC forum as I originally posted there and thought this might be an issue with TC in the way it is launching the configured editors. But turns out it's not. Works as expected with other editors, even with relative path addressing. You might wonder why relative paths at all - this is due to the setup some users employ, keeping all tools as portable as possible but still interconnected with each other, hence the relative path addressing.
Which brings me back to how to reproduce the bug. No, you don't need TC at all. Really just open a cmd.exe from Windows start menu, use the cd command to change to your PSPad directory and enter these commands in the cmd.exe window:
Posted by: pspad | Date: 2021-01-11 05:34 | IP: IP Logged
I will test it with CMD, I will catch what is happening and try to fix it.
Posted by: pspad | Date: 2021-01-25 20:17 | IP: IP Logged
I have good news, I hope this problem is solved.
Posted by: X-Byte | Date: 2021-01-25 22:15 | IP: IP Logged
Awesome Very happy to hear that you really dug deep into that issue that most other users probably won't experience and solved it.
Thanks a lot - very much appreciated