lentinant
lentinant

Reputation: 832

WbemObject.Terminate failure reason

As for now, I'm improving logging in my Inno Setup installer, so if consumer will get some sort of error, I can easily see, what went wrong.

As one of installation actions, I kill application process, if it is running, to overwrite files gracefully. To kill application, I use approach, which is described in question Inno Setup Kill a running process - getting WbemObject and calling WbemObject.Terminate.

As for now, I want to track, if Terminate was successful. From my testing, I've found out, that it actually returns boolean, indicating, whether application was terminated successfully. But if it fails, it simply returns "false". And I want to know more detailed reason.

So, is there way to get actual failure reason for WbemObject.Terminate?

Upvotes: 1

Views: 131

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202474

What you have, is not WbemObject, it's Win32_Process object.

The Win32_Process.Terminate method does return uint32 (Cardinal in Pascal), not Boolean:

Returns a value of 0 (zero) if the process was successfully terminated, and any other number to indicate an error. For additional error codes, see WMI Error Constants or WbemErrorEnum. For general HRESULT values, see System Error Codes.

Successful completion (0)
Access denied (2)
Insufficient privilege (3)
Unknown failure (8)
Path not found (9)
Invalid parameter (21)
Other (22–4294967295)

Upvotes: 1

Related Questions