首页 文章

从python脚本运行powershell命令时出现系统错误

提问于
浏览
0

我试图在Windows PowerShell上运行以下python脚本,这会抛出以下错误

错误:

术语“x86”未被识别为cmdlet,函数,脚本文件或可操作程序的名称 . 检查名称的拼写,或者如果路径包含d,请验证路径是否正确,然后重试 .

脚本:

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)

1 回答

  • 0

    你能试一下吗 :

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

    我对python不太满意,我只想将路径括在双引号 "" 中 .

相关问题