Link to home
Start Free TrialLog in
Avatar of hillch
hillch

asked on

VBScript runtime error: Permission denied: 'GetObject'

This script remotely retrieves the status of the "Patch Link" service from Windows XP workstations. When it works the workstation's Ip address and service status is written to a file.  Here is a success result.
192.168.10.20 - Patch Link Installed AND is Running
When it fails it is failing because it does not have permissions to access the workstation.  Here is the error.
C:\Scripts\Ck4PatchLink.vbs(24, 3) Microsoft VBScript runtime error:  Permission denied: 'GetObject'
Here is line 24 from the code.
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & 
      "\root\cimv2")

Here are the things I have done.
1.  Verified the script is logging on to the remote workstation using the administrator account.
2.  Verified administrator passwords.

3.  Verified WMI security by => Right-Click 'My Computer' >> Manage >> Expand 'Services and Applications' >> Right-click 'WMI Control' >> Properties >> 'Security' tab >> Expand 'Root' >> Select CIMV2 and click security and verify that the account you are using has the appropriate perms and also check you have appropriate perms on the WMI location as well (normally "C:\WINDOWS\System32\WBEM"

4.  Verified there are no firewalls between the two computers.

5.  Confirmed that the script runs locally on the remote workstation.

6.  There are no DCOM errors on the remote or local workstations.

7.  Check DCOM on both workstations by start > run > dcomcnfg > expand component services > computers > right click on "my computer" > "default properties" tab > make sure enable distributed com on this computer is selected > default authentication level is "connect" and default impersonation level is "identity" > reboot if necessary

8.  Workstations have been rebooted.
Dim strComputer 
Dim ServerList
Dim fsoRead, fsoWrite, strPathLinkResult
Dim strDirectory, strFile, objTextFile 
Const ForAppending = 8
 
strDirectory = "C:\Scripts\"
strFile = "Ck4PatchLink_Results.txt"
 
'On Error Resume Next
 
set fsoRead = CreateObject("Scripting.FileSystemObject")
set fsoWrite = CreateObject("Scripting.FileSystemObject")
Set objTextFile = fsoWrite.OpenTextFile(strDirectory & strFile, forAppending, True)
set ServerList = fsoRead.OpenTextFile("C:\Scripts\ServerList.txt", 1)
 
while not ServerList.AtEndOfStream
  strComputer = ServerList.readline
 
  Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer &
      "\root\cimv2")
 
  Set colRunningServices = objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName = 'PatchLink Update'")
 
  For Each objService in colRunningServices 
     If err.number = 0  Then
      WScript.Echo(strComputer  & " - Patch Link Installed AND is " & objService.State)
      strPathLinkResult = strComputer  & " - Patch Link Installed AND is " & objService.State
     Else
       WScript.Echo(strComputer  & " - Patch Link is NOT Installed OR 
        there is an Error Accessing the Workstation.")
       strPathLinkResult = strComputer  & " - Patch Link is NOT 
        Installed OR there is an Error Accessing the Workstation."
     End If
  Next
 
objTextFile.WriteLine(strPathLinkResult)
 
WScript.echo "VBScript Error: " & err.number
 
Wend
 
objTextFile.Close
ServerList.close
msgbox "All Done"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Um - how come a "B"?