Without any sample code it is a bit hard to guess what the problem could be!
You can set a specific exit code with SetErrorLevel
.
As far as ExecWait goes, setting anything makes no sense, when it returns the child process has ended. If you want to use the exit code of a child process all you need is to get it:
ExecWait '"c:\foo.exe"' $0
SetErrorLevel $0