簡體   English   中英

VBScript到Python代碼段的轉換

[英]VBScript to Python snippet conversion

我正在嘗試將此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

我正在運行Windows 7 32位,安裝了Python 2.7.3Python for Windows Extensions 我還通過從... “ Lib \\ site-packages \\ win32com \\ client \\”執行“ makepy.pyc”來添加COM對象,但沒有運氣,總是會收到一些錯誤消息...

這是我的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)

有誰可以幫助我進行這次對話嗎?

Dispach應該應該是Dispatch

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM