Running VBScript inside Python : Error Microsoft VBScript runtime error: ActiveX component can't create object

Running VBScript inside Python : Error Microsoft VBScript runtime error: ActiveX component can't create object

好吧,我在 python 代码中调用 VBScript。我收到错误消息“ActiveX 组件无法创建对象” 但是当我调用 Seperate 时很好(当我双击它或使用 cmd 运行)时。

这是 python 代码的一部分。我尝试了 csript、wscript。将路径更改为 system32 / SYSVOW64.. 但没有任何效果

for i in range(printInput):
    print("range")
    print(i)
    os.system(r"C:\Windows\system32\cmd.exe /k c:\windows\SysWOW64\cscript.exe  C:\Users\muneeb.kalathil\PycharmProjects\moodledownload\vcconverter\labelprint\new.vbs")
    #subprocess.call("run.bat")

这是 VBSscript

'<SCRIPT LANGUAGE="VBScript">
    ' Data Folder
    Const sDataFolder = "C:\Users\muneeb.kalathil\PycharmProjects\moodledownload\vcconverter\labelprint\"
    DoPrint(sDataFolder & "label.lbx")

    '*******************************************************************
    '   Print Module
    '*******************************************************************
    Sub DoPrint(strFilePath)
        Set ObjDoc = CreateObject("bpac.Document")
        bRet = ObjDoc.Open(strFilePath)
        If (bRet <> False) Then
            ObjDoc.GetObject("AssetName").Text = "text"
            ObjDoc.GetObject("AssetTag").Text = "text"
                        ObjDoc.GetObject("company").Text = "text"
                        
                        Call ObjDoc.SetBarcodeData(ObjDoc.GetBarcodeIndex("QR"), "link")

            ' ObjDoc.SetMediaByName ObjDoc.Printer.GetMediaName(), True
            ObjDoc.StartPrint "", 0
            ObjDoc.PrintOut 1, 0
            ObjDoc.EndPrint
            ObjDoc.Close
        End If
        Set ObjDoc = Nothing
    End Sub

显示

中的错误
Set ObjDoc = CreateObject("bpac.Document")

所以经过多次尝试,我将vbscript转换为exe文件然后执行。现在可以使用了。

os.system("run.exe")

我用过这个软件,因为有些转换器并没有真正转换成exe。该软件有一些限制。但对我来说效果很好。

https://www.battoexeconverter.com/