Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error -2147217405 with no description?

Status
Not open for further replies.

Vachaun22

Programmer
Oct 7, 2003
171
US
I'm getting error number -2147217405 after this line of code is executed:

Code:
	Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    	strComputer & "\root\default:StdRegProv")

However, there is another VBScript file I have that uses this exact line of code to do exactly what I'm trying to do, yet it succeeds. Any suggestions?
 
What is the value of strComputer at the time of the error ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The value of strComputer is set to our domain controller's machine name with is ML350 initialized as such:

Code:
Const strComputer = "ML350"

However, I was incorrect when I said the other script worked. It does not work with restricted permissions.

So the code mentioned before is functional as long as the privileges are elevated. So I either need to figure out how to enumerate shared printers with VBScript on a remote machine, or how to elevate the privileges in the script to have access to read the registry on the remote computer.
 
If you have an admin account you can use to access your DC, then you can use something like this to connect using those alternate credentials and read the registry:

Code:
strUser = "administrator"
strPwd = "sdf@#Sdf#"
strKeyPath = "SOFTWARE\BuildVersion" 
strValueName = "BuildID"

Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMI = SWBemlocator.ConnectServer(strComputer ,"root\default",strUser, strPwd)
Set objRegistry = objWMI.Get("StdRegProv")

objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strBuildID

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top