如何从PS1文件运行WinSCP [英] How to run a WinSCP from ps1 file

查看:64
本文介绍了如何从PS1文件运行WinSCP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本中有一个.ps1文件.在此脚本中,我有一行:

I have a .ps1 file with my script. In this script I have a line with:

Start-Process "C:\activatebatch.bat"

如果我直接使用ps1文件执行它,则一切正常.但是,如果我将Windows Scheduler设置为ps1作为执行程序,则bat文件不会启动.在该bat文件中,我有一个WinSCP,它将文件发送到服务器.

If i execute it directly with ps1 file, everything works well. But if I set up a Windows Scheduler with ps1 as executive, the bat file doesn't start. In that bat file I have a WinSCP which sends file to server.

我如何设置它从Windows Scheduler中存储的.ps1启动.bat?或者如何直接从PowerShell代码执行WinSCP?

How could I set it to start .bat from .ps1 stored in Windows Scheduler? Or how could I execute WinSCP directly from PowerShell code?

我需要它来调用WinSCP将文件发送到服务器-并且选项存储在批处理文件中:

I need it to call for WinSCP to send a file into server - and the options are stored in batch file:

"C:\Program Files (x86)\WinSCP\WinSCP.exe" user:password@IPI.PIP.IP.IP /command ^
    "put C:\ss\file.txt /home/scripts/windows/" ^
    "exit"

推荐答案

如果批处理文件中有运行的WinSCP命令行,则可能需要进行一些更改以使其与PowerShell兼容:

If you have a working WinSCP command line in a batch file, you may need to do few changes to make it compatible with PowerShell:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆