1

I am executing below command through autosys(scheduling tool) to stop a service but it is failing with below error. The command works fine when i run the command on RUN(WIN+R) or cmd after RDPing into the server. Can anyone help me here with a right command?

Command: C:\windows\System32...powershell Start-Process powershell -Verb runAs E:\ABC\stop_service.ps1

Content of stop_service.ps1 = stop-service -name 'service-abc'

Error: Start-Process : This command cannot be run due to the error: This operation requires an interactive window station.

At line:1 char:1 + Start-Process powershell -Verb runAs E:\ABC\stop_service.ps ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOp erationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

0

To execute a powershell session :

Powershell.exe -ExecutionPolicy Bypass -File stop_service.ps1

You can directly run the Stop-Service command as :

Powershell.exe -ExecutionPolicy Bypass -Command {Stop-Service -Name <ServiceName> -Force}

Note: For better results, please make sure to run the command under Administrator context

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.