Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > RE: Read registry on remote computer (with alternate credentials)

Reply
Thread Tools Display Modes

RE: Read registry on remote computer (with alternate credentials)

 
 
urkec
Guest
Posts: n/a

 
      09-26-2008
"Jo" wrote:

> Hello,
>
> Sorry for my very bad English...
>
> I have a problem when I tried to read registry on remotes computers.
> The code must run under VBA Excel. The final purpose is to extract
> from print servers the list of installed printers with ip address.
> Remotes servers are on various domains without trusts relationships
> and various OS like W2003, W2K and NT4.
>
> When I use this code:
>
> Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
> oReg = objSWbemLocator.ConnectServer(strSrvName, "root
> \default:StdRegProv", strDomain & "\" & strUser, strPassword)



You're missing a Set here, SWbemLocator.ConnectServer returns SWbemServices
object (even if you include the class name in the namespace path)

strSrvName = "."

Set objSWbemLocator = CreateObject _
("WbemScripting.SWbemLocator")

Set oReg = objSWbemLocator.ConnectServer _
(strSrvName, "root\default:StdRegProv")

Debug.Print TypeName(oReg)

Set StdRegProv = oReg.Get("StdRegProv")

For Each Method In StdRegProv.Methods_
Debug.Print Method.Name
Next


(I was only able to test this locally)


In the second code snippet you also missed a Set:


strSrvName = "."

Set objSWbemLocator = CreateObject _
("WbemScripting.SWbemLocator")

' Need Set here:
Set objSWbemServices = objSWbemLocator.ConnectServer _
(strSrvName, "root\default")

Set oReg = objSWbemServices.Get("StdRegProv")

For Each Method In oReg.Methods_
Debug.Print Method.Name
Next




--
urkec
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I write a script to read a remote registry - using different credentials? Mark Scripting 3 01-16-2008 04:03 PM
ADO with alternate credentials Steve Scripting 2 11-03-2005 01:08 PM
Re: edit registry other computer with other user credentials Torgeir Bakken \(MVP\) Scripting 0 06-01-2004 06:34 PM
WMI Read remote registry OMG Scripting 1 02-11-2004 11:52 PM
Remote Computers - Alternate Credentials JO Sabor Scripting 0 11-11-2003 01:30 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59