使用 comtype 创建 COM 对象时出现异常

Exception while creating a COM object with comtype

在我的一个项目中,我们使用 comtypes 来远程控制 GUI 应用程序以实现自动化测试。如果手动调用测试,一切似乎都很顺利,但如果 jenkins 正在执行测试用例,则可能会发生

抛出一个奇怪的 OSError
from comtypes.client import CreateObject

app=createObject("App")

错误读数是:

OSError: [WinError -2147467238] The server processs could not be started, as the configured identity is wrong. Check your username and password.

有谁知道如何解决这个问题?

错误被表述为 here

CO_E_RUNAS_LOGON_FAILURE
0x8000401A

请使用this answer检查在您的手动和自动测试中哪个用户正在执行脚本,我很确定它们是不同的。