python - 使用powershell执行的批处理文件在远程机器上启动python
问题描述
我想使用命令行参数运行位于远程机器上的 python 脚本。
我正在使用 power shell 命令执行批处理文件
powershell.exe -Command "invoke-command -computername testmachinename -credential testcred -scriptblock {start-process c:\test\test.bat -ArgumentList "Arg1", "Arg2"}"
而 test.bat 看起来像
echo %time% "Started" >> C:\test\Log.txt 2>&1
set arg1=%1
set arg2=%2
echo arg1 %arg1% >> C:\test\Log.txt 2>&1
echo arg2 %arg2% >> C:\test\Log.txt 2>&1
cd C:\Test\
start cmd.exe
start C:\Dev\Anaconda3\python.exe test.py >> C:\test\Log.txt 2>&1
回声和集合工作正常。但是在执行 cmd.exe 或 python.exe 时,它什么也不做。
当我从远程机器上的命令行手动运行批处理文件时,它工作正常。
我错过了什么吗?
解决方案
推荐阅读
- ftp - lftp 550 权限被拒绝
- python - Python - 虽然不重复
- php - PHP - 从 JSON 中获取价值
- powershell - 如何使用 PowerShell CIM 在远程计算机上获取和/或设置注册表值?
- javascript - 如何在 XML 树中查找值的节点位置?
- r - 拒绝采样从 Cauchy 样本中生成 Normal 样本
- kubernetes - TCP Ingress 与 Istio 0.8 和 v1alpha3 网关
- javascript - ReasonML javascript 记录字段
- ios - Swift:从 AppDelegate 标签更新 UILabel 不会更新
- php - 在codeigniter中使用foreach循环更新字段不起作用