v8.51a (and also v8.01/v7.xx) – Error of launching programs

Please report only one bug per message!

Moderators: Stefan2, white, sheep, Hacker

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

Post by *MarcinW » 2014-09-26, 22:42 UTC

ghisler(Author) wrote:Another idea: Would it help if TC just added the directory from GetSystemWindowsDirectory to its PATH variable? Windows seems to look in the path when launching a program by name only. Or maybe internally set %windir%?
I tried this and it seems that ShellExecute doesn't use any environment variables at all:
- I added GetSystemWindowsDirectory path to the %path% variable - doesn't help,
- changing %windir% is useless - %windir% always points to the true Windows directory.

ghisler(Author) wrote:
Yes, this definitely works.
That's strange, programs launched from TC would inherit it's environment variables, so %windir% should be pointing to the wrong location...
%windir always points to the true Windows directory, but ShellExecute doesn't use this variable - it internally calls GetWindowsDirectory function.

When EXE is launched on a server machine and it doesn't have IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE flag set, operating system - before passing control to the application - loads tsappcmp.dll application compatibility library for this application. Kernel32.dll looks for tsappcmp.dll and - if loaded - redirects, among others, GetWindowsDirectory calls there - so GetWindowsDirectory returns a "fake" Windows directory.

So TC has tsappcmp.dll loaded and GetWindowsDirectory returns "fake" Windows directory for TC. But when TC launches some application with IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE flag set, OS doesn't load tsappcmp.dll library for that application. When that application calls ShellExecute, ShellExecute internally calls GetWindowsDirectory - it is NOT redirected for that application, so it returns true Windows directory - so ShellExecute can succesfully launch REG files, when called from application with IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE flag set.

So TC could launch a small tool with this flag set, and this tool could successfully open REG files with ShellExecute.

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

Post by *ghisler(Author) » 2014-09-29, 10:43 UTC

OK, then it is a bug of ShellExecute - if you are a big corporate user, you should report this as a bug to Microsoft. They should be using GetSystemWindowsDirectory in ShellExecute, it makes no sense at all to use GetWindowsDirectory here. I don't think that there is anything I can do to fix this myself inside TC. :(
Author of Total Commander
http://www.ghisler.com

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

Post by *MarcinW » 2014-09-29, 17:06 UTC

Definitely, I also consider this behavior as a Windows bug. They should in ShellExecute call GetWindowsDirectory, but - if searching for the application there fails - also call GetSystemWindowsDirectory.

What do you think about adding a small launcher tool to TC, with the IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE flag set? This would be a solution.

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

Post by *ghisler(Author) » 2014-10-02, 09:49 UTC

I don't know how well this will work, because the called program may be checking for the launcher's main window, or TC may need the window or process handle of the called process.
Author of Total Commander
http://www.ghisler.com

Post Reply