-1
import subprocess
command = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c ". \"C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\""'
subprocess.call(command,shell=True)

I use to this code but i recived error on powershell

add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
At C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1:25 char:2

1 Answers1

0

Hi Try with this:-

import os

command = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c ". \"C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\""'
os.system(command)
#or
os.system(command,shell=True)
Abhijit Pritam Dutta
  • 5,521
  • 2
  • 11
  • 17
  • check the power shell commend. The problem is with your power shell command not with python code. First manually execute the power shell and check whether work or not. – Abhijit Pritam Dutta Feb 20 '18 at 22:55