1

I need to test automatically if an executable has no missing dll at starting. This checking is done with Jenkins (continuous integration) which can execute batch scripts.

Despite all my tests, I can't find a way with a batch script to start an executable and get an error code if there is one or more missing dll.

It works fine with "CALL myexecutable.exe" which returns a code different from 0 when a dll is missing(-1073741515) but, obviously, I need to stop the program manually.

I tried lots of things with the command "START" by mixing several batch scripts (one which do the CALL and the other which kill the process of the executable after a sleep of few seconds, ect...) but the only way I found to have a code different from 0 when there is missing dll is with "CALL myexecutable.exe"...

EDIT : Actually, to simplify, I search a way to detect that an exe started from a batch file failed at start (but for the moment, I didn't find a way to close the program automatically because when a dll is missing, a dialog box with an error message appears). I don't care to know which dll is involved. In my case, I can do the assumption that if the program failed at start, the reason is a missing dll.

Someone have an idea to help me ?

tcsiradel
  • 11
  • 3
  • IMO that's not possible. Even if there are .dlls referenced in the program not present in the path how would you know from outside if they are required in the current situation? –  Jun 30 '17 at 10:31
  • A very naive approach would be to use strings.exe from sysinternals to search programm code for .dll files and check if they are in the path with `For /f "delims=" %A in ('strings -n 7 YourProgram.exe^|findstr /i "\.dll"') do @where /Q "%A"||@Echo %A not found` –  Jun 30 '17 at 10:37
  • Actually, all dll needed are in the same directory than the exe. I would like to check automatically with Jenkins if the installer (.msi) of the program deploys all the dll needed even if someone adds a new functionnality which requires a new dll and he forgot to add it to the installer. But if this is not possible, I will forget this idea. – tcsiradel Jun 30 '17 at 12:01
  • I can't know if a dll is required from outside the program but when you execute an exe with missing dll, an error message appears and the program stops. I thought there was a way to detect the failed of the program with an error code (and that is the case with the batch command CALL but the program need to be stop manually). – tcsiradel Jun 30 '17 at 12:08

1 Answers1

0

Dependency Walker would allow an indirect way of catching unresolved DLLs.

depends.exe /c /ot:a-ldd.txt a.exe
findstr "Error: " a-ldd.txt > nul && echo unresolved

Windows OS appears to check a registry setting before popping up its alerts. This allows blocking pop-ups for the entire machine, I guess.

reg query HKLM\SYSTEM\CurrentControlSet\Control\Windows
reg add HKLM\SYSTEM\CurrentControlSet\Control\Windows /v ErrorMode /t REG_DWORD /f /d 2

I have yet to find a way to disable pop-ups per process. An answer to a question on suppressing crash alerts implies that the SetErrorMode call affects only the current process (my attempts to suppress the missing DLL alert when launching the executable from a PowerShell script after calling SetErrorMode(0x8003) failed).

eel ghEEz
  • 1,186
  • 11
  • 24