Hey guys what's up, I am a total n00b to this whole scripting thing and I have this code pasted below which works perfectly on your local machine but I am trying to connect to a remote machine how/where do I set the user credentials in the code below.
Any suggestion or comments are appreciated.
Thanks In Advance
ScarEye
sComputer = "." computer
sService = "RemoteRegistry"
Set oInstance = GetObject("winmgmts:{impersonationLevel=impersonate}//" & sComputer & _
"/root/cimv2:Win32_Service=" & Chr(34) & sService & Chr(34))
Set oOutParam = oInstance.ExecMethod_("StopService")
If oOutParam.ReturnValue = 0 Then
WScript.Echo oInstance.Name & " stopped successfully"
Else
WScript.Echo oInstance.Name & " failed to stop"
Select Case oOutParam.ReturnValue
Case 1 WScript.Echo "The request is not supported."
Case 2 WScript.Echo "The user did not have the necessary access."
Case 3 WScript.Echo "The service cannot be stopped because other " & _
"services that are running are dependent on it."
Case 4 WScript.Echo "The requested control code is not valid, or " & _
"it is unacceptable to the service."
Case 5 WScript.Echo "The requested control code cannot be sent to " & _
"the service because the state of the service."
Case 6 WScript.Echo "The service has not been started."
Case 7 WScript.Echo "The service did not respond to the stop request " & _
"in a timely fashion."
Case 8 WScript.Echo "Unknown failure when stopping the service."
Case 9 WScript.Echo "The directory path to the service executable was not found."
Case 10 WScript.Echo "The service is already stopped"
Case 11 WScript.Echo "The service database is locked."
Case 12 WScript.Echo "A dependency which this service relies on " & _
"has been removed from the system."
Case 13 WScript.Echo "The service failed to find the service needed " & _
"from a dependent service."
Case 14 WScript.Echo "The service has been disabled from the system."
Case 15 WScript.Echo "The service does not have the correct authentication " & _
"to run on the system."
Case 16 WScript.Echo "This service is being removed from the system."
Case 17 WScript.Echo "There is no execution thread for the service."
Case 18 WScript.Echo "There are circular dependencies when stopping the service."
Case 19 WScript.Echo "There is a service running under the same name."
Case 20 WScript.Echo "There are invalid characters in the name of the service."
Case 21 WScript.Echo "Invalid parameters have been passed to the service."
Case 22 WScript.Echo "The account, which this service is to run under is " & _
"either invalid or lacks the permissions to run the service."
Case 23 WScript.Echo "The service exists in the database of services " & _
"available from the system."
Case 24 WScript.Echo "The service is currently paused in the system."
End Select
End If
Any suggestion or comments are appreciated.
Thanks In Advance
ScarEye
sComputer = "." computer
sService = "RemoteRegistry"
Set oInstance = GetObject("winmgmts:{impersonationLevel=impersonate}//" & sComputer & _
"/root/cimv2:Win32_Service=" & Chr(34) & sService & Chr(34))
Set oOutParam = oInstance.ExecMethod_("StopService")
If oOutParam.ReturnValue = 0 Then
WScript.Echo oInstance.Name & " stopped successfully"
Else
WScript.Echo oInstance.Name & " failed to stop"
Select Case oOutParam.ReturnValue
Case 1 WScript.Echo "The request is not supported."
Case 2 WScript.Echo "The user did not have the necessary access."
Case 3 WScript.Echo "The service cannot be stopped because other " & _
"services that are running are dependent on it."
Case 4 WScript.Echo "The requested control code is not valid, or " & _
"it is unacceptable to the service."
Case 5 WScript.Echo "The requested control code cannot be sent to " & _
"the service because the state of the service."
Case 6 WScript.Echo "The service has not been started."
Case 7 WScript.Echo "The service did not respond to the stop request " & _
"in a timely fashion."
Case 8 WScript.Echo "Unknown failure when stopping the service."
Case 9 WScript.Echo "The directory path to the service executable was not found."
Case 10 WScript.Echo "The service is already stopped"
Case 11 WScript.Echo "The service database is locked."
Case 12 WScript.Echo "A dependency which this service relies on " & _
"has been removed from the system."
Case 13 WScript.Echo "The service failed to find the service needed " & _
"from a dependent service."
Case 14 WScript.Echo "The service has been disabled from the system."
Case 15 WScript.Echo "The service does not have the correct authentication " & _
"to run on the system."
Case 16 WScript.Echo "This service is being removed from the system."
Case 17 WScript.Echo "There is no execution thread for the service."
Case 18 WScript.Echo "There are circular dependencies when stopping the service."
Case 19 WScript.Echo "There is a service running under the same name."
Case 20 WScript.Echo "There are invalid characters in the name of the service."
Case 21 WScript.Echo "Invalid parameters have been passed to the service."
Case 22 WScript.Echo "The account, which this service is to run under is " & _
"either invalid or lacks the permissions to run the service."
Case 23 WScript.Echo "The service exists in the database of services " & _
"available from the system."
Case 24 WScript.Echo "The service is currently paused in the system."
End Select
End If