Hey All,
Last week i was running this code with a non privileged user and it seemed to work fine. I have tested it on a remote computer that was in a workgroup as well as a computer that was in our active directory domain.
Now when I run it against the computer that is in a workgroup I get the Permission Denied error when the "Set objComputer = GetObject("WinNT://" & strPrimaryNCR & ",computer")" runs and if I run it against a computer in our AD domain it get a Access Denied Error when "Set objService = objComputer.GetObject("service", "Symantec Antivirus")" runs
I was surprised this even worked last week. I would have thought I would need an admin account to check to see of a service was running, now I think I might. If I make that account running the scrip admin the script runs again.
Any idea why it would have worked last week and not this week?. Nothing should have changes on either of the test computers. And if I do need admin rights is there a way to pass in admin credentials into the getobject method?
Thanks
Jesse
' Check to see if the service is running
strComputer = “MyTest01”
Set objComputer = GetObject("WinNT://" & strComputer & ",computer")
Set objService = objComputer.GetObject("service", "Symantec Antivirus")
If objService.Status = 4 Then
Msgbox "The service is running"
Else
MsgBox "The service is NOT running"
End If
End If
Last week i was running this code with a non privileged user and it seemed to work fine. I have tested it on a remote computer that was in a workgroup as well as a computer that was in our active directory domain.
Now when I run it against the computer that is in a workgroup I get the Permission Denied error when the "Set objComputer = GetObject("WinNT://" & strPrimaryNCR & ",computer")" runs and if I run it against a computer in our AD domain it get a Access Denied Error when "Set objService = objComputer.GetObject("service", "Symantec Antivirus")" runs
I was surprised this even worked last week. I would have thought I would need an admin account to check to see of a service was running, now I think I might. If I make that account running the scrip admin the script runs again.
Any idea why it would have worked last week and not this week?. Nothing should have changes on either of the test computers. And if I do need admin rights is there a way to pass in admin credentials into the getobject method?
Thanks
Jesse
' Check to see if the service is running
strComputer = “MyTest01”
Set objComputer = GetObject("WinNT://" & strComputer & ",computer")
Set objService = objComputer.GetObject("service", "Symantec Antivirus")
If objService.Status = 4 Then
Msgbox "The service is running"
Else
MsgBox "The service is NOT running"
End If
End If