【问题标题】:How to run Windows powershell script from python?如何从 python 运行 Windows PowerShell 脚本?
【发布时间】:2021-02-07 20:36:05
【问题描述】:

我想在 Powershell 中运行一个类似于图片中的脚本,但来自 python。 [1]:https://i.stack.imgur.com/K7XGI.png 比如我想要这样的代码:

def run(namefile):
    command that opens powershell
    command that type in the powershell .\spim.exe .\namefile.txt
    command that run the script

有人知道怎么做吗?

【问题讨论】:

    标签: python windows powershell


    【解决方案1】:

    如果你只想运行exe文件,你可以使用subprocess module

    如果你真的想在 Powershell 终端中运行它,你可以使用 -Command option 运行 Powershell 二进制文件。

    【讨论】:

      猜你喜欢
      • 2010-11-09
      • 2019-12-02
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      相关资源
      最近更新 更多