Skip to main content

CreateProcess Windows API does not start a Process from an EXE

  • February 15, 2013
  • 0 replies
  • 1 view

Problem:

CreateProcess Windows API does not start a Process.

The CreateProcess was being used to start an EXE. However this was returning the value 0. A zero from the API denotes failure to start the process.

How can you find out why the process could not be started ?

Resolution:

The CreateProcess API will return 0 when it does not start a process. However if you get an error (zero) retrurned you can call the GetLastError API to retrieve more infomation.

Code such as:

01  ws-retval       DWORD.

    call winapi "GetLastError" retrurning ws-retval

will allow you retieve the reason for the error.

In the case if the customer problem a 2 was returned from GetLastError. A return code of 2 is:-

"The system cannot find the file specified."

This was caused because the EXE that had to be run was not on the PATH. Windows will search down PATH for EXE file. Ensuring that the EXE was on the PATH resolved the problem.

Old KB# 4324