Meaningful error message when program start fails

Here you can propose new features, make suggestions etc.

Moderators: Stefan2, white, sheep, Hacker

User avatar
Dalai
Power Member
Power Member
Posts: 6147
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2018-06-03, 14:09 UTC

Uh, this is not about Windows 10. I'm testing on XP (and Win2k where my Delphi is), because it's easier in this particular case.

OK, to summarize: TC 9.20 beta5 shows "Access denied" in its own error dialog (not the Windows one) when trying to launch FB-Traffic on XP - just like it did in previous betas/versions. My test program shows "%1 is not a valid Win32 application", similar to the Windows message when launching the file via TC's context menu. Logic tells me there is something different in TC, maybe FormatMessage doesn't get the message from the system or it's lost somewhere before it gets to the user. As I already said, I don't know what I can do to assist you.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
j7n
Member
Member
Posts: 132
Joined: 2005-08-07, 21:56 UTC

Post by *j7n » 2018-06-03, 20:54 UTC

Thank you for looking into this issue I have also raised in the past.

I confirm that Beta 5 still doesn't display a correct error message on 2k/XP/2008/Seven for programs that require new subsystem version (increasingly common) or 64-bit machine. It now shows two lines of access denied instead of one like in the past.

Access denied!
"Access is denied."

For 64-bit binaries, x86 NT6.0 provides a helpful message that is a paragraph long (but not shown in TC).

"The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86..." (they could simplify and just tell the required version...)

Is it not possible to make double-click perform the same action as launching an exe from explorer/right-click with all error dialogs?

The double error reminds me of doors in video game Half-Life.
#148174 Personal license
Running Total Commander v8.52a

User avatar
Dalai
Power Member
Power Member
Posts: 6147
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2018-06-04, 15:07 UTC

j7n wrote:It now shows two lines of access denied instead of one like in the past.

Access denied!
"Access is denied."
This is done when TC's language differs from the OS language or the error message is potentially different. This should work for "simple" error texts that don't contain placeholders like %1, like the one you mentioned regarding x64 programs on 32 bit Windows.
For 64-bit binaries, x86 NT6.0 provides a helpful message that is a paragraph long (but not shown in TC).
Yes, that's another good test case which Ghisler can use. Apparently even that error text isn't shown by TC, because it also contains a placeholder:
Windows wrote:This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
Note that this error text slightly differs from the one shown by Explorer. Thus I searched where the error texts come from, and it looks like the FormatMessage function reads the error texts (in this case) from kernel32.dll(.mui), while Explorer reads it from shell32.dll(.mui).
Is it not possible to make double-click perform the same action as launching an exe from explorer/right-click with all error dialogs?
Well, the goal of this thread is that TC shows the same error text as Windows does, and with the suggested code it can be achieved. Ghisler just needs to find out what he does differently in TC. In the end, it's not the same action, but at least the end result (the error text) is the same.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 36245
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2018-06-05, 07:45 UTC

It's probably because I'm not using GetLastError, but instead use the error returned in hInstApp:
If the function fails, it is set to an SE_ERR_XXX error value that indicates the cause of the failure.
I will try using GetLastError instead.
Author of Total Commander
http://www.ghisler.com

User avatar
Dalai
Power Member
Power Member
Posts: 6147
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2018-06-05, 14:14 UTC

Aha! Well, you could use both GetLastError and hInstApp, but as I see it, the latter only contains some generic error code that is not really helpful.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 36245
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2018-06-06, 16:34 UTC

Yes indeed! In Beta 6, I'm now using GetLastError. Please let me know whether it makes any difference. I have also extended the buffer to 1024 characters.
Author of Total Commander
http://www.ghisler.com

User avatar
j7n
Member
Member
Posts: 132
Joined: 2005-08-07, 21:56 UTC

Post by *j7n » 2018-06-06, 19:34 UTC

The error message works now in all cases I tried (subsystem, x64, bad certificate). However, a literal "%1" is shown. Maybe you can replace it with the name of the exe file to make the text nicer for non-technical users.
#148174 Personal license
Running Total Commander v8.52a

User avatar
Dalai
Power Member
Power Member
Posts: 6147
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2018-06-06, 20:52 UTC

Ah, what a relief! Finally useful error texts in that message box, thank you!
j7n wrote:However, a literal "%1" is shown. Maybe you can replace it with the name of the exe file to make the text nicer for non-technical users.
I second that. @Ghisler: I guess that, if you don't want FormatMessage to handle that replacement, a simple StringReplace of %1 with the executable name would be enough. In other words, I wouldn't bother with placeholders starting from %2.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 36245
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2018-06-07, 09:01 UTC

I will check it.
Author of Total Commander
http://www.ghisler.com

User avatar
DrShark
Power Member
Power Member
Posts: 1111
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark » 2018-06-07, 09:44 UTC

It seems following may be related to the issue described here.
I treid to launch exe (c:\ProgramData\Microsoft\Windows\WER\ReportQueue\tc920x32_64_b3.exe) from a dir where NTFS rights don't allow this (at least here on Vista 32 bit) from TC 9.20 beta 6.
TC 9.20 beta 6 on Vista 32 bit still shows simple "Access denied" error:

Code: Select all

---------------------------
Total Commander
---------------------------
Access denied!



"Отказано в доступе."
---------------------------
ОК   
---------------------------
When to try to launch it from context menu, Windows shows following error:

Code: Select all

[Window Title]
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\tc920x32_64_b3.exe
[Content]
Отказано в доступе к указанному устройству, пути или файлу. Возможно,  у вас нет нужных прав доступа к этому объекту.

[ОК]
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW » 2018-06-14, 11:14 UTC

I can confirm that %1 is replaced with the executable name now :)

User avatar
DrShark
Power Member
Power Member
Posts: 1111
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark » 2018-06-16, 10:09 UTC

For my sample case TC 9.20 RC1 now also shows file name in error window:

Code: Select all

---------------------------
Total Commander
---------------------------
Access denied on file
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\tc920x32_64_b3.exe!



"Отказано в доступе."
---------------------------
ОК   
---------------------------
but the error text is still different from one in Windows error window (see original post). Should it be like that?
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
Dalai
Power Member
Power Member
Posts: 6147
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2018-06-16, 15:05 UTC

I can confirm DrShark's findings. Unfortunately, I don't know why this happens. Even my test program doesn't show anything more than "Access denied" when NTFS permissions don't allow the execution of executables. It seems that GetLastError doesn't help in finding the reason why the execution failed in such a case. I wonder what Explorer does beyond that ...

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
j7n
Member
Member
Posts: 132
Joined: 2005-08-07, 21:56 UTC

Post by *j7n » 2018-06-16, 15:22 UTC

The longer message doesn't provide more information. It just repeats the basic error in two long sentences. "Access is denied. Perhaps you don't have access rights." It gives an illusion of more information, but doesn't really say whether the access restriction is on the "device, path or file". I think the two words are sufficient if they aren't shown for the other cases that have nothing to do with "access".
#148174 Personal license
Running Total Commander v8.52a

Post Reply