Files
zerorigin-toolbox/deploy/configure-wer.py
T
zerorigin2019 0a1c1e82ea chore: 初始化仓库(零源工具箱 0.1.0 基线)
- Go 主进程 cmd/zerorigin(托盘常驻 + 触发器/规则/动作引擎)
- Wails v3 设置进程 cmd/settings(独立 module)
- 监督进程 cmd/watchdog(-supervise 异常重启)
- 构建脚本 build.bat / NSIS 安装包 deploy/、便携版 portable/
- 架构与 MVP 计划文档 docs/、阶段 0-4 验收记录 deploy/acceptance-0-4.md
2026-08-05 00:42:45 +08:00

41 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""配置 Windows WER LocalDumps:ZerOriginTool 崩溃时自动生成完整转储,
用于定位"进程静默消失"问题(原生异常取证)。用户级注册表,无需管理员权限。
用法: python configure-wer.py
"""
import os
import sys
import winreg
APPS = ["ZerOriginTool.exe", "ZerOriginTool-Settings.exe"]
BASE = r"Software\Microsoft\Windows\Windows Error Reporting\LocalDumps"
def main() -> int:
dump_folder = os.path.join(os.environ["LOCALAPPDATA"], "ZerOriginTool", "crashdumps")
try:
os.makedirs(dump_folder, exist_ok=True)
except OSError as e:
print(f"[error] 创建转储目录失败: {e}")
return 1
for app in APPS:
key_path = f"{BASE}\\{app}"
try:
with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_WRITE) as k:
winreg.SetValueEx(k, "DumpFolder", 0, winreg.REG_EXPAND_SZ, dump_folder)
winreg.SetValueEx(k, "DumpType", 0, winreg.REG_DWORD, 2) # 2 = full dump
winreg.SetValueEx(k, "DumpCount", 0, winreg.REG_DWORD, 5)
except OSError as e:
print(f"[error] 写入 {key_path} 失败: {e}")
return 1
print(f"[ok] {app} -> {dump_folder} (full dump, 保留 5 份)")
print("[done] WER LocalDumps 配置完成。崩溃转储将写入: " + dump_folder)
return 0
if __name__ == "__main__":
sys.exit(main())