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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permission Denied GetObject

Status
Not open for further replies.

chinnashara

Technical User
Dec 12, 2007
27
US
Hi All,

I tried to get a script which bounces the services on a machine.
The script seems to be working fine on a local machine..but when i try to stop the services on a remote machiens am getting the below error...

Error: Permission Denied: 'GetObject'
Code:800A0046.

Below is the script which i used...


strService = "ERsvc"
strComputer = "WISBLRDP071"

WScript.Echo "Restarting " & strService & "..."

' Stop dependent services
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objServiceList = objWMI.ExecQuery("Associators of " _
& "{Win32_Service.Name='" & strService & "'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Antecedent" )
For Each objService In objServiceList
WScript.Echo " Stopping " & objService.Name
objService.StopService()
Next

Please can some one help me
 
try this instead

GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Hi,

Thanks for the update..but it still throwing the same error

Error: Permission Denied: 'GetObject'

Regards,
Sharath.M
 
Do you have administrative rights on the remote box? If so, does the script work locally on that box? If it does work locally but not remotely try checking the DCOM settings.

on the box you're having issues with
start > run > dcomcnfg > expand component services > computers > right click on "my computer" > "defaul 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

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Hi,

I have the admin rights and the script works on my local machiens but when I try to restart a service for a remote computer am getting the error and infact the DCOM setting are good.

Regards,
Sharath.M
 
Any firewalls enabled?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
No firewalls are enabled and even I tried on my test machines but dint found any use. Do you have any other script or reference to restart a services on remote machines.

Regards,
Sharath.M
 
Have you checked the security setting in WMI control on the machines? 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top