使用Powershell执行的批处理文件在远程计算机上启动python

时间:2018-09-07 15:23:21

标签: python powershell batch-file

我想使用命令行参数运行位于远程计算机上的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时,它什么也不做。

当我从远程计算机上的命令行手动运行批处理文件时,它运行正常。

我想念什么吗?

0 个答案:

没有答案