简体   繁体   中英

System Error on running a powershell command from a python script

I am trying to run following python script on windows powershell which is throwing following error

ERROR:

The term 'x86' is not recognized as the name of a cmdlet, function, script file , or operable program. Check the spelling of the name, or if a path was include d, verify that the path is correct and try again.

SCRIPT:

import os
import sys

Watchdog_config = 'C:\\Program Files (x86)\\Common Files\\ibm\\icc\\cimom\\data\\wmia.properties'
command1 = "PowerShell -Command \"& {(cat "+Watchdog_config+" )|%{$_ -replace {\"off\",\"on\"}}|set "+Watchdog_config+"}\""

os.system(command1)

Can you try :

Watchdog_config = '\"C:\\Program Files (x86)\\Common Files\\ibm\\icc\\cimom\\data\\wmia.properties\"'

I'am not confortable with python, I just want to enclose path into double quotes "" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM