-1

I am trying to restart WinRM with python. I tried different combination of quotes, single, double or no quotes and nothing works, getting "returned non-zero exit status 1"

(pyenv) C:>python
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 16:30:00) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess,sys
>>> subprocess.check_output("powershell.exe Start-Service -Name “WinRM”")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'powershell.exe Restart-Service -Name “WinRM”' returned non-zero exit status 1.
irom
  • 3,316
  • 14
  • 54
  • 86

1 Answers1

0

I found out that admin rights were root cause of my issue, windows command prompt has to be started with admin rights and then python repl

irom
  • 3,316
  • 14
  • 54
  • 86