I am attempting to start/stop services via a script. The command is
sc stop "service name"
It is failing with this error
{SC} OpenService FAILED 123:
Any assistance would be appreciated.
I am attempting to start/stop services via a script. The command is
sc stop "service name"
It is failing with this error
{SC} OpenService FAILED 123:
Any assistance would be appreciated.
reported an {SC} OpenService FAILED 123 error; correctly identified the root cause as a mismatch between the friendly Display Name and the service's internal key (short) name, and reminded that a target machine must be specified for remote operations. The error code 123 corresponds to an invalid name being passed to the Service Control Manager, so SC was simply being asked to open a service that does not exist under the given identifier.
How to resolve and avoid this in scripts:
sc getkeyname "Display Name" or a PowerShell query such as Get-Service -DisplayName "Display Name" | Select-Object -ExpandProperty Name to obtain the correct key name for scripting.If problems persist after using the correct key name, verify the service still exists, inspect event logs on the target for more detail, and try a local control attempt on the target host to rule out network or permission issues.
Jump to Post— cguan_77 8have you tried:
sc \\servername stop "service name"
have you tried:
sc \\servername stop "service name"
And be sure to use the Service Name, not the display name. check via ..
sc query
And be sure to use the Service Name, not the display name. check via ..
sc query
That was it. I used this script several months ago and it worked using the display name. Using the service name as displayed with the query commmand worked. thanks a million.
Occasionally it would, because sometimes Service Name is the same as the Display Name, as you would have noticed.
Cheers.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.