|
| |||||||||
| Tags: alternate, credentials, registry |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Read registry on remote computer (with alternate credentials)
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) I always receive the error message "The object doesn't support this property or method...". I have tried this syntax: Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") objSWbemServices = objSWbemLocator.ConnectServer(strSrvName, "root \default", strDomain & "\" & strUser, strPassword) Set oReg = objSWbemServices.Get("StdRegProv") with the same effect. Thank's for your help. Jo PS: ConnectServer on other namespace like root\cimv2 works fine for other purpose but in same context (domain, servers, user...) |
|
#2
| |||
| |||
| RE: Read registry on remote computer (with alternate credentials)
"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 |
|
#3
| |||
| |||
| Re: Read registry on remote computer (with alternate credentials)
On Sep 26, 10:33*pm, urkec <ur...@discussions.microsoft.com> wrote: > "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 Many Thank's to you. Now it work fine. Thank's again. Jo |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Read registry on remote computer (with alternate credentials)" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remote Desktop Connection not using saved credentials | Tamas | Networking & Security | 7 | 20-07-2011 04:22 AM |
| The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer | MR-KEN | Windows Server Help | 5 | 24-12-2010 02:07 PM |
| How to read the registry before .NET | HarshaB | Software Development | 4 | 29-10-2009 08:51 AM |
| Remote Desktop on Server 2008: This computer can't connect to the remote computer | bense1983 | Operating Systems | 7 | 28-07-2009 02:24 PM |
| how can I write a script to read a remote registry - using different credentials? | Mark | Windows Server Help | 3 | 16-01-2008 10:33 PM |