Comfy-Org / Comfy-Org/ComfyUI

comfy-aimdo failed to load: [WinError 4551] - Windows "Bad Image" dialog on startup (v0.18.0)

Open
#13,088 3 comments 0 reactions 1 assignee Claimed by @rattus128 View on GitHub
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

## Description
On a fresh ComfyUI v0.18.0 Windows portable install, starting `run_nvidia_gpu.bat`
immediately shows a Windows error dialog:

> **python.exe - Ungültiges Bild** (Bad Image)
> `aimdo.dll is either not designed to run on Windows or it contains an error`

In the log: `comfy-aimdo failed to load: [WinError 4551]`

## Environment
- ComfyUI v0.18.0 Windows Portable (NVIDIA)
- Windows 11, NVIDIA Driver 591.86
- PyTorch 2.10.0+cu130 (CUDA 13.0)
- comfy-aimdo 0.2.12

## Root Cause
`comfy_aimdo/control.py` calls `ctypes.CDLL("aimdo.dll")` without first suppressing
Windows critical error dialogs via `SetErrorMode`. Windows shows the "Bad Image" dialog
**before** Python's `except` block can handle the error.

Importantly: the DLL **loads successfully** on compatible systems — the dialog is a
false alarm caused by missing error mode setup.

## Fix
Either in `comfy_aimdo/control.py` or before calling `comfy_aimdo.control.init()`
in `main.py`, suppress the dialog:

```python
if system == "Windows":
kernel32 = ctypes.WinDLL("kernel32")
old_mode = kernel32.SetErrorMode(0x8007)
try:
lib = ctypes.CDLL(str(base_path / "aimdo.dll"))
finally:
kernel32.SetErrorMode(old_mode)

This restores the original error mode afterwards, so no side effects.

---

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.