简体   繁体   中英

VBScript to Python snippet conversion

I'm trying to convert this VBScript code to Python (Win32) code but with no luck!

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. Also I added COM object by executing "makepy.pyc" from ... "Lib\\site-packages\\win32com\\client\\" and with no luck, always getting some error message...

Here is my Python code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM