首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >用于启动远程Python脚本的Windows命令

用于启动远程Python脚本的Windows命令
EN

Stack Overflow用户
提问于 2018-07-10 03:50:44
回答 1查看 2.6K关注 0票数 0

我正在寻找使用一个Windows命令来运行远程Python脚本的最快方法。到目前为止,我已经了解了Powershell,但是我似乎需要使用Invoke-Command远程启动一个远程Powershell脚本,然后该脚本将在本地启动Python脚本。有没有更简单、更直接的方法来做到这一点?

EN

回答 1

Stack Overflow用户

发布于 2018-07-10 08:49:29

使用Invoke-Command来实现这一点,它就是为此而设计的。

代码语言:javascript
复制
Invoke-Command -ComputerName $computerName {
  # Assumes python.exe is on the remote $env:PATH
  # and that you are running a python file, not module
  python \path\to\file.py
}

作为一个额外的好处,如果你想同时在几台计算机上运行,-ComputerName也允许你传入一组计算机名,如下所示:

代码语言:javascript
复制
Invoke-Command -ComputerName computer1, computer2, computer3, computerX {
  # Assumes python.exe is on the remote $env:PATH
  # and that you are running a python file, not module
  python \path\to\file.py
}

You can read more about Invoke-Command here.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51253045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档