Converting from VB? Partial success...

  • Thread starter benjamin schollnick
  • Start date
B

benjamin schollnick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top