Converting from VB? Partial success...

benjamin schollnick bscholln at mac.com
Wed Oct 29 02:47:51 CET 2003



I am attempting to convert the following VB Script code to Python, but
with limited success.

I appear to be connecting fine, but I can't get the registry information
out...  I can get the manifest, and I do have the correct permissions
with the user account that I am using...

The VB code works, so it is a issue with the python implementation...


------------------------ VB Code -----------------------------
Const HKEY_CURRENT_USER = &H80000001

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer("13.1.99.43",
"root\default",
"operator", "spire")
objWMIService.Security_.ImpersonationLevel = 3
set objRegister = objWMIService.get("StdRegProv")

Dim arrValues
strKeyPath = "Software\SCITEX\GUI"
strKey = "Version"
objRegister.GetStringValue HKEY_CURRENT_USER, strKeyPath, strKey, value

Wscript.Echo value
-------------------------------------------------------------------------
-


import _winreg
import win32com.client

HostName = "remote_ip"     # local host
login_account = "account name"
account_pass  = "password"

strKeyPath = r"\HKEY_LOCAL_MACHINE\SOFTWARe\Microsoft\DrWatson"
strKey = r"AppendToLogFile"

HKLM = 0x80000001L

objLocator = win32com.client.Dispatch ("WbemScripting.SWbemLocator")
print dir(objLocator)
objWMIService = objLocator.ConnectServer (HostName, "root\default",
login_account, account_pass)
objWMIService.Security_.ImpersonationLevel = 3
print dir(objWMIService.__class__)
   #
   #  Dir is showing a "generic" dynamic listing???  Why?
   #
#print objWMIService.__doc__
objRegister = objWMIService.Get ("StdRegProv")
test = objRegister.GetObjectText_ ( 1 )
#test2 = objRegister.GetStringValue_ ( "SOFTWARE\Microsoft\DrWatson",
"AppendToLogFile" )
print test2 # Print's the manifest
#print test




More information about the Python-list mailing list