| Previous | Next |
| ERROR_INVALID_BLOCK | ERROR_BAD_FORMAT |
ERROR_BAD_ENVIRONMENT
The process environment is malformed
ERROR_BAD_ENVIRONMENT is returned when Windows cannot interpret an environment block. This can happen when manually constructing the block for process creation, using the wrong character format, omitting required termination, or passing corrupted data.
Checks
- For Unicode process creation, use a sorted double-null-terminated wide-character block.
- Ensure each entry has the form
NAME=value. - Do not pass pointers to temporary or already freed storage.
- Prefer the inherited environment unless custom values are required.
Handling
Rebuild the block from validated name-value pairs and preserve the correct encoding flags. Log names, but avoid logging secret values.
References
Looking for a different code? Search another status or error code.