We help IT Professionals succeed at work.
Get Started

Error Number: 70 -  Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

2,492 Views
Last Modified: 2013-12-09
I am writing a script to do a mass registry change for all workstations listed in computer.txt. The problem is I can't seem to get past this error. I don't know what else to change. Weird thing is, I did a similar script before and it worked with no issues.. I can't see the difference in what I did. I am trying to run this on Windows XP SP2 Pro machines.

I have commented out the error handling to get the error number.
I get error 70 and then it fails to continue on. The code runs fine except the unability to get past the setObjReg part.. it will spit error 70 and skip the registry changes and then basically keep looping until the list of computers is done and then it ends.

Basically the script is supposed to remove registry keys that initiate an uninstall password. I do this so I can do a mass uninstallation of Symantec and switch to McAfee.
'-------------------- Grab computer names from Computer.txt and store in array ----------------
strComputers = ""
 
On Error Resume Next
 
'Initialize global constants and variables.
Const FOR_READING = 1
g_strHostFile = "computer.txt"
 
'Read computer names for install from text file.
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If objFSO.FileExists(g_strHostFile) Then
  Set objTextStream = objFSO.OpenTextFile(g_strHostFile, FOR_READING)
Else
  WScript.Echo "ERROR: Input file " & g_strHostFile & " not found."
  WScript.Quit
End If
 
'--Loop through list of computers and perform tasks on each.--
 
Do Until objTextStream.AtEndOfStream
  readingInComputer= objTextStream.ReadLine
  strComputers = strComputers + readingInComputer +","
Loop
objTextStream.Close
 
Const HKEY_LOCAL_MACHINE = &H80000002
arrComputers = Split(strComputers , ",")
 
For Each strComputer in arrComputers
On Error Resume Next
  '---- If computername is blank then exit loop ---
  If strComputer = "" Then 
     WScript.Echo "End List"
     exit for
  End If
 
 '----------- Set Uninstall Password & LockUnloadSvcs Registry Key Values-------
 
 Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
 
' ----If getObject fails, server is offline or doesn't exist -------------
 'If err.number <> 0 then
	WScript.Echo "ERROR: " & err.number & " " & strComputer & " is offline or access is denied"
	err.clear
 '------ Else GO ahead and remove Registry Keys ---------------------
' Else
'   err.clear
 
 
 
 '------ remove Registry Keys ---------------------
 
   strKeyPath = "SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\AdministratorOnly\Security"
 
   ValueName = "LockUnloadServices" 
   objReg.GetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue
   If strValue<>0 Then
	WScript.Echo strComputer & " LockUnload - 0"
      objReg.setDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, 0
   End If
 
 
   ValueName = "UseVPUninstallPassword" 
   objReg.GetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue
   If strValue<>0 Then
	WScript.Echo strComputer & " VPUninstall - 0"
     objReg.setDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, 0
   End If
 
 
SET objReg=Nothing
 
'End If
Next
 
'Let user know the script is done!
WScript.Echo "SCRIPT IS DONE, YO!!!"

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE