Windows Command Prompt cm_ExecuteDOS WinExec() ShellExecute

English support forum

Moderators: white, Hacker, petermad, Stefan2

lucatrv
Junior Member
Junior Member
Posts: 9
Joined: 2014-02-16, 17:29 UTC

Windows Command Prompt cm_ExecuteDOS WinExec() ShellExecute

Post by *lucatrv »

The "Windows Command Prompt" is not fully function

Please find a description of the issue at the following links:

https://cygwin.com/ml/cygwin/2017-10/msg00162.html
https://cygwin.com/ml/cygwin/2017-10/msg00163.html
https://cygwin.com/ml/cygwin/2017-10/msg00223.html

Initially I reported it on the Cygwin mailing list because I thought it was related to gcc on Windows, then I realized it is actually related to the Total Commander's Command Prompt.




Moderation:
Subject line modified.
Jump to explanation post of the author
> viewtopic.php?p=333774#333774
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

What executable did you compile, 32 or 64 bit? Which TC version and architecture did you use exactly? How exactly did you start the program, double-click or menu Commands > Open command prompt window or something else?

In short, please provide more information. Currently I have my doubts that TC is the culprit.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Total commander simply starts the program defined via COMSPEC environment variable, which is usually cmd.exe - but may be changed on your system. I haven't heared of any programs which wouldn't run from such a command prompt.
Author of Total Commander
https://www.ghisler.com
lucatrv
Junior Member
Junior Member
Posts: 9
Joined: 2014-02-16, 17:29 UTC

Post by *lucatrv »

I compiled a 64 bit executable, using the 'x86_64-w64-mingw32-gcc' command as described in the first post linked above.
I am using TC 9.0a 64 bit, on Windows 7 64 bit.
I executed the program as follows: with TC navigate to the 'foo.exe' folder, click on menu Commands > Open command prompt window, execute 'foo.exe' + enter (I do not get any message).
If instead I open the Windows Command Prompt form the Start Menu, cd to the 'foo.exe' folder, and execute 'foo.exe' + enter I get the error message window shown in the second post linked above.
Unfortunately I cannot attach 'foo.exe' here, but it should be fairly easy to reproduce this issue following the instructions above.
You can also reproduce this issue with other (probably with all) binaries linked to a dll. For instance, if you have GIMP installed, you can reproduce it by renaming 'libcairo-2.dll' to something else, and executing 'gimp-2.8.exe' first in the Command Prompt opened from TC, and then in the Command Prompt opened from the Start Menu.
User avatar
Stefan2
Power Member
Power Member
Posts: 4124
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Hmm, 'paper chase' ? ( 'Schnitzeljagd' )

If I would have the time to clean up your description, I would get something like this:

Why I get no message if I launch the executable from TC command line?


I am using TC 9.0a 64 bit, on Windows 7 64 bit.


I compiled a 64 bit executable, using the 'x86_64-w64-mingw32-gcc' command as described in the first post linked above.

This executable should use the 'libfoo.dll', but I renamed them for an test so it can not be found.


... if I run a program compiled with 'gcc' without the proper shared libraries in path I get the following error message:
> error while loading shared libraries: libxxx.so: cannot open shared object file: No such file or directory
This is expected.


With Windows Command Prompt I get that message too:
If instead I open the Windows Command Prompt form the Start Menu, cd to the 'foo.exe' folder,
and execute 'foo.exe' + enter I get the error message window
---------------------------
foo.exe - System Error
---------------------------
The program can't start because libfoo.dll is missing from your computer. Try
reinstalling the program to fix this problem.
---------------------------
OK
---------------------------




But with TC I see no message:
I executed the program as follows: with TC navigate to the 'foo.exe' folder,
click on menu Commands > Open command prompt window,
execute 'foo.exe' + enter (I do not get any message).





So why I get no message if I launch the executable from TC command line?
Correct?




 
lucatrv
Junior Member
Junior Member
Posts: 9
Joined: 2014-02-16, 17:29 UTC

Post by *lucatrv »

Correct. And this happens also with other (may be all) binaries not finding required dlls (e.g. GIMP with libcairo). Please try yourself.
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Did you start TC as administrator? What happens when you launch cmd.exe via TC by navigating to C:\Windows\system32 and double click on cmd.exe?

OK, I tested your suggestion with GIMP now (had it installed anyway) and I can confirm the issue. Interestingly adding a button like this

Code: Select all

TOTALCMD#BAR#DATA
%SystemRoot%\System32\cmd.exe

%SystemRoot%\System32\cmd.exe


0
-1
or adding CMD to TC's start menu works just fine. Menu Commands > Open command prompt must do something different than the button bar or start menu.

But at least you have a workaround until the bug is fixed.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
lucatrv
Junior Member
Junior Member
Posts: 9
Joined: 2014-02-16, 17:29 UTC

Post by *lucatrv »

I tried to start TC as administrator and the result is the same (no error message window).
If I launch 'cmd.exe' via TC by navigating to 'C:\Windows\system32' and double clicking on 'cmd.exe', I get the correct error message window (same as running the Command Prompt from the Start Menu).
So I guess the TC menu 'Commands > Open command prompt window' does something else.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

It's probably because of a security feature: TC is set to not load any dlls from the current directory, because this can be used by viruses to inject their own dlls. Instead, the dll must be in the windows, system32, or one of the PATH directories.

wincmd.ini
[Configuration]
DllLoad=0

Set DLL load method for plugins and Explorer extensions:
-1: Never from current dir (most secure)
0: Only in context menu (needed e.g. for "Send To" with Outlook 2003)
1: always also from current dir (as TC7.55a and older)
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

2ghisler(Author)
I don't think this is the culprit. It's neither cmd.exe nor TC that is missing a DLL but the program that is launched by CMD (which itself has been launched via cm_ExecuteDOS). Furthermore I can also reproduce it with TC 7.04a, which - according to the help excerpt - should load all DLLs also from the current directory. And that still doesn't explain the difference between a button/start menu and cm_ExecuteDOS.

Please try it for yourself, e.g. with GIMP.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I see - so what IS the culprit? Do I need to launch cmd.exe with special parameters?
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

2ghisler(Author)
Not sure what the culprit is exactly (that's up to you to find out ;)), but the problem is this: A program is missing a DLL. In one case it tells the user about it, in another case it doesn't.

Summary:
  • Open a CMD window (via TC's command line by typing C:\Windows\system32\cmd.exe, the button bar or TC's start menu). In the CMD window navigate to the program's directory and launch the program. It will show a window that says that it's missing a DLL and which one.
  • Open a CMD window via cm_ExecuteDOS (Commands > Open command prompt). In the CMD window navigate to the program's directory and launch it. It will not show anything about the missing DLL!
To make it clear: In both cases the program won't start, it's only about the error message about the missing DLL. You can do this with any program that requires some DLL to load, I made my tests with GIMP (renamed libcairo-2.dll as was suggested by lucatrv). It also works with VLC by renaming libvlc.dll. It must be some DLL that is in the EXE's import table.

Regards
Dalai
Last edited by Dalai on 2017-10-23, 14:55 UTC, edited 1 time in total.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
ffFan
Junior Member
Junior Member
Posts: 23
Joined: 2005-12-28, 09:53 UTC
Location: Rheinland-Pfalz

Post by *ffFan »

Hello

I think it depends on whether it is a windows programm or not.

I tested it with inkscape and renaming "libpangomm-1.4-1.dll to "_libpangomm-1.4-1.dll"

Executing portable inkscape (inkscape.com) within:

1. commando line (Kommandozeile), I get the error message box
2. commando line window (Befehle->Kommandozeilenfenster öffnen) no error box occured.

Regards
ffFan
User avatar
Stefan2
Power Member
Power Member
Posts: 4124
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Win7/32 - TC8.51a

I am in the right folder.
Renamed 'libcairo-2.dl-l'


Double click in TC panel at 'gimp-2.8.exe' >> got the message.

Execute 'gimp-2.8.exe' from TC command line >> got the message.

Launch Windows Start > cmd > CD to folder > 'gimp-2.8.exe' >> got the message.



Have a Button
cmd /k

C:\Windows\system32\cmd.exe

>> 'gimp-2.8.exe' >> got the message.




Execute cm_ExecuteDOS and there in DOS 'gimp-2.8.exe' - no message :shock:


---------------------------
gimp-2.8.exe - Systemfehler
---------------------------
Das Programm kann nicht gestartet werden, da libcairo-2.dll auf dem
Computer fehlt. Installieren Sie das Programm erneut, um das Problem
zu beheben.
---------------------------
OK
---------------------------



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

Post by *ghisler(Author) »

Command line sets current directory to the directory of the active panel. If the program only looks in current directory for the dll, then it will not find it.
Author of Total Commander
https://www.ghisler.com
Post Reply