[英]VBScript to Python snippet conversion
I'm trying to convert this VBScript code to Python (Win32) code but with no luck! 我正在尝试将此VBScript代码转换为Python (Win32)代码,但是没有运气!
Dim objMain, objSysInf, stMsg
Set objMain = CreateObject("nnetcom.oMain")
Call objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")
Set objSysInf = CreateObject("nnetcom.oSystemInfo")
Call objSysInf.GetSystemInfos
stMsg = objSysInf.cOsName & " " & objSysInf.cOsType & vbCrLf & _
objSysInf.cOsCpu & vbCrLf & objSysInf.cOsMem & vbCrLf & _
objSysInf.cOsGpu
MsgBox stMsg, vbInformation, "System Information"
Set objSysInf = Nothing
Set objMain = Nothing
I'm running Windows 7 32-bit with Python 2.7.3 and Python for Windows Extensions installed. 我正在运行Windows 7 32位,安装了Python 2.7.3和Python for Windows Extensions 。 Also I added COM object by executing "makepy.pyc" from ... "Lib\\site-packages\\win32com\\client\\" and with no luck, always getting some error message...
我还通过从... “ Lib \\ site-packages \\ win32com \\ client \\”执行“ makepy.pyc”来添加COM对象,但没有运气,总是会收到一些错误消息...
Here is my Python code: 这是我的Python代码:
import pythoncom
import win32com.client
objMain = win32com.client.Dispach("nnetcom.oMain")
ret = objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")
objSysInf = win32com.client.Dispach("nnetcom.oSystemInfo")
objSysInf.GetSystemInfos()
stMsg = objSysInf.cOsName
print(stMsg)
Is there anybody who can help me with this conversation? 有谁可以帮助我进行这次对话吗?
Dispach
应该应该是Dispatch
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.